Last active
June 29, 2016 13:53
-
-
Save lesniakania/a6057012d41f37bd2faa2082115941f8 to your computer and use it in GitHub Desktop.
“new” Keyword in the Constructor or at Field Declaration
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
class House | |
attr_reader :bedroom | |
def initialize(bedroom) | |
@bedroom = bedroom | |
end | |
def enough_space?(people_count) | |
bedroom.beds_count >= people_count | |
end | |
end | |
describe House do | |
it "tests something important in House" do | |
# Awesome, I can use test doubles that | |
# are lighter weight. | |
# ... | |
dummy_bedroom = instance_double('Bedroom', beds_count: 2) | |
house = House.new(dummy_bedroom) | |
expect(house.enough_space?(1)).to be true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment