Initial add#54
Initial add#54andrewpetit wants to merge 1 commit intopaircolumbus:masterfrom andrewpetit:add-apetit
Conversation
| end | ||
|
|
||
| def add_apples | ||
| rn = Random.new |
There was a problem hiding this comment.
You don't have to initialize a new generator to use rand. It's an alias for Random::DEFAULT.rand so you can get away with just writing rand(1..10) here.
|
|
||
| def any_apples? | ||
| if(@apples == nil || @apples.count <= 0) | ||
| return false |
There was a problem hiding this comment.
no need for explicit returns here.
| end | ||
|
|
||
| def any_apples? | ||
| if(@apples == nil || @apples.count <= 0) |
There was a problem hiding this comment.
why might we want to use the getter here instead and anywhere else we can in this class?
| end | ||
| end | ||
|
|
||
| class Tree < AppleTree |
There was a problem hiding this comment.
Slight nitpick. I might rename this with AppleTree inheriting from Tree.
| end | ||
|
|
||
| describe 'Fruit' do | ||
| describe AppleTree do |
There was a problem hiding this comment.
Take a look at contexts. I would use those to refactor my tests into a story with a clear happy path and not so happy path.
| end | ||
|
|
||
| def dead? | ||
| if(@age > 50) |
There was a problem hiding this comment.
You could also write this...
def dead?
return true if age > 50
false
end|
|
||
| it 'dead? returns true if greater than 50' do | ||
| appleTree = AppleTree.new(1, 55, [], true) | ||
| expect(appleTree.dead?).to eq true |
There was a problem hiding this comment.
rspec also has dynamic predicate matchers which are pretty cool.
https://relishapp.com/rspec/rspec-expectations/v/3-6/docs/built-in-matchers/predicate-matchers
No description provided.