Last active
June 23, 2016 00:51
-
-
Save ClayShentrup/f4d4a48193dc36c4f8b1ff3f82a7b787 to your computer and use it in GitHub Desktop.
names_for_let_objects 2
This file contains 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
module NamesForLetObject | |
def names_for_let_objects(objects) | |
objects.map { |object| name_for_let_object(object) } | |
end | |
def name_for_let_object(object) | |
__memoized.instance_variable_get(:@memoized).key(object) | |
end | |
end |
This file contains 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
expected collection contained: [:user_1] | |
actual collection contained: [:user_1, :user_2] | |
the extra elements were: [:user_2] |
This file contains 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(User) do | |
describe('.old_enough_to_drink') do | |
let!(:bob) { create(:user, age: 21) } | |
let!(:alice) { create(:user, age: 20) } | |
def result | |
names_for_let_objects(User.all) | |
end | |
specify do | |
expect(result.to eq([:bob]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe that
users_spec.rb
line 7 should bedescribed_class.old_enough_to_drink
to be at parity with the 'before' example.Looks good. I am going to be linking to it in my own list of engineering principles and techniques.