-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matt Crocco solution & tests #52
base: master
Are you sure you want to change the base?
Conversation
|
||
def initialize | ||
def initialize(max_possible_age=10, max_growth: 3, apple_color: 'orange') | ||
raise ArgumentError, 'Ages must be positive and non-zero' if max_possible_age <= 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. One thing you'll see are custom errors. Something like...
class Tree
class AgeError < StandardError; end
def initialize
`raise AgeError.new(msg)`
end
end
end | ||
|
||
def age! | ||
@age += 1 | ||
|
||
if @age > @max_age |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
end | ||
|
||
it 'starts out alive' do | ||
expect(tree).not_to be_dead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
expect(tree).not_to be_dead | ||
end | ||
|
||
it 'starts out with no apples' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the story approach of your tests. Keep in mind using contexts to improve readability.
No description provided.