-
Notifications
You must be signed in to change notification settings - Fork 71
Sheshtawy #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
Open
sheshtawy
wants to merge
4
commits into
paircolumbus:master
Choose a base branch
from
sheshtawy:sheshtawy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sheshtawy #74
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
798e8ee
Add tree initialization and its tests
sheshtawy d2de97b
add implementation to different tree functionalities and their tests"
sheshtawy fb105d3
Update tree instance variables accessors
sheshtawy b2c0d6f
Remove unnecessary return statement
sheshtawy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,90 @@ | |
| require_relative '../lib/tree' | ||
|
|
||
| describe Tree do | ||
| let(:tree) { Tree.new(1, [], true, 1) } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice use of |
||
|
|
||
| it 'should be a Class' do | ||
| expect(described_class.is_a? Class).to eq true | ||
| end | ||
|
|
||
| it 'is born with the age of 1' do | ||
| expect(tree.age).to be 1 | ||
| end | ||
|
|
||
| it 'is born with the height of 1 foot' do | ||
| expect(tree.height).to be 1 | ||
| end | ||
|
|
||
| it 'is born alive' do | ||
| expect(tree.alive).to be true | ||
| end | ||
|
|
||
| it 'is born with no apples' do | ||
| expect(tree.apples.length).to be 0 | ||
| end | ||
|
|
||
| # TODO age! should modify age ?! | ||
| it 'ages by one year everytime age! is called' do | ||
| tree.age = 1 | ||
| tree.age! | ||
| expect(tree.age).to be 2 | ||
| end | ||
|
|
||
| it 'grows n apples if add_apples is called with n number of apples' do | ||
| tree.add_apples 10 | ||
| expect(tree.apples.length).to be 10 | ||
| end | ||
|
|
||
| it 'returns true if the tree has grown apples' do | ||
| tree.add_apples(1) | ||
| expect(tree.any_apples?).to be true | ||
| end | ||
|
|
||
| it 'returns false if the tree has no apples' do | ||
| expect(tree.any_apples?).to be false | ||
| end | ||
|
|
||
| it 'returns an apple when pick_an_apple is called' do | ||
| expect(tree.any_apples?).to be false | ||
| tree.add_apples 1 | ||
| expect(tree.pick_an_apple!).to be_an_instance_of(Apple) | ||
| expect(tree.any_apples?).to be false | ||
| end | ||
|
|
||
| it 'raises an error if the tree has no apples' do | ||
| expect { tree.pick_an_apple! }.to raise_error(NoApplesError) | ||
| end | ||
|
|
||
| it 'is dead when calling dead? is returns true' do | ||
| tree.age = 50 | ||
| tree.age! | ||
| expect(tree.dead?).to be true | ||
| end | ||
|
|
||
| it 'is alive when calling dead? returns false' do | ||
| expect(tree.dead?).to be false | ||
| end | ||
| end | ||
|
|
||
| describe 'Fruit' do | ||
| describe Fruit do | ||
|
|
||
| context 'when initialized' do | ||
| it { is_expected.to be_an_instance_of(Fruit) } | ||
| end | ||
|
|
||
| end | ||
|
|
||
| describe 'Apple' do | ||
| describe Apple do | ||
| let(:apple) {Apple.new('green', 10)} | ||
|
|
||
| it 'is a Fruit' do | ||
| expect(apple).to be_a_kind_of(Fruit) | ||
| end | ||
|
|
||
| it 'has seeds' do | ||
| # TODO Apple should be a subclass of Fruit | ||
| expect(apple).to be_an_instance_of(Apple) | ||
| #expect(apple::has_seeds).to be_true | ||
| end | ||
|
|
||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
see: https://stackoverflow.com/a/612653