Skip to content

Instantly share code, notes, and snippets.

@lesniakania
Last active June 29, 2016 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lesniakania/a6057012d41f37bd2faa2082115941f8 to your computer and use it in GitHub Desktop.
Save lesniakania/a6057012d41f37bd2faa2082115941f8 to your computer and use it in GitHub Desktop.
“new” Keyword in the Constructor or at Field Declaration
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