- ActiveRecordError
- AdapterNotFound
- AdapterNotSpecified
- AssociationNotFoundError
- AssociationRelation
- AssociationTypeMismatch
- Associations::Builder::Association
- Associations::Builder::BelongsTo
- Associations::Builder::CollectionAssociation
- Associations::Builder::HasMany
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe ExampleController, type: :controller do | |
describe '#show' do | |
context 'third party API returns 404' do | |
before do | |
stub_request(:get, "www.example.com"). | |
to_return(body: {error: "record not found"}.to_json, status: 404) | |
get :show | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#optimal is the actual count we want to maximize. {optimal: 4} | |
#means we want to find as many sets of 4s as possible. | |
#without optimal set, we will optimize for the biggest values possible. | |
def groups(books, optimal: nil) | |
#convert list of books to list of counts of each book type | |
#sort by descending order for optimal grouping | |
#eg: [1,1,2,2,3,3,4,5] => [2,2,2,1,1] | |
counts = books.inject({}) do |res, item| | |
res[item] ||= 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
extend Test::Unit::Assertions | |
class FibonacciAggregator | |
def self.sum_of_even_numbers(limit: 4_000_000) | |
sum, lower, higher = 0, 1, 2 | |
while lower <= limit | |
sum += lower if lower % 2 == 0 | |
lower, higher = higher, lower + higher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
extend Test::Unit::Assertions | |
class FibonacciAggregator | |
class << self | |
def sum_of_even_numbers(limit: 4_000_000, debug_mode: false) | |
sum_of_numbers(limit: limit, debug_mode: debug_mode) do |number| | |
number % 2 == 0 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ruby-dictionary' | |
class BoggleGame | |
attr_accessor :tiles, :words, :dictionary, :input | |
def initialize(array_of_array) | |
@tiles = [] | |
@words = [] | |
@input = array_of_array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Task | |
attr_accessor :name, :parent | |
def initialize(name) | |
@name = name | |
@parent = nil | |
end | |
def get_time_required | |
0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CompositeTask < Task | |
def initialize(name) | |
super(name) | |
@sub_tasks = [] | |
end | |
def add_sub_task(task) @sub_tasks << task task.parent = self | |
end | |
def remove_sub_task(task) @sub_tasks.delete(task) task.parent = nil | |
end | |
def get_time_required |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"ident_custom1": { | |
"email": "{{ssmtp_root}}" | |
}, | |
"ident_custom2": { | |
"email": "{{ssmtp_root}}" | |
}, | |
"ident_sales": { | |
"email": "{{ssmtp_root}}" | |
}, | |
"ident_support": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
people = People.new.add_dir('./data') | |
puts 'Output 1:' | |
people.sort(gender: :asc, last_name: :asc).print | |
puts | |
puts 'Output 2:' | |
people.sort(birthday: :asc).print | |
puts | |
puts 'Output 3:' | |
people.sort(last_name: :desc).print |
NewerOlder