Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Matt Crocco solution & tests #52

wants to merge 2 commits into from

Conversation

glossawy
Copy link

@glossawy glossawy commented Jun 5, 2017

No description provided.

@glossawy
Copy link
Author

glossawy commented Jun 5, 2017

@jaybobo @jack-chester


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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

www.betterspecs.org/#contexts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants