Skip to content

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

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