Last active
June 29, 2016 13:51
-
-
Save lesniakania/90b0a962285ac272728b947d325d90a0 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.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