Skip to content

Instantly share code, notes, and snippets.

@lesniakania
Last active June 29, 2016 13:51
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/90b0a962285ac272728b947d325d90a0 to your computer and use it in GitHub Desktop.
Save lesniakania/90b0a962285ac272728b947d325d90a0 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.new
end
def enough_space?(people_count)
bedroom.beds_count >= people_count
end
end
describe House do
it "tests something important in House" do
# Darn! I'm stuck with those object created in the
# constructor.
# ...
house = House.new
# ... ?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment