-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added age method and can drink check. #2
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,9 +39,45 @@ | |
end | ||
end | ||
|
||
describe '.age=' do | ||
it 'sets the age for our human instance' do | ||
human = Human.new('') | ||
expect(human).to respond_to(:age=) | ||
end | ||
end | ||
|
||
describe '.age' do | ||
it 'it returns the age' do | ||
human = Human.new('') | ||
human.age = 18 | ||
expect(human.age).to eq(18) | ||
end | ||
end | ||
|
||
describe '.can_drink?' do | ||
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. great work that you put all the expectations inside of one describe block |
||
it 'returns true if human is of age' do | ||
human = Human.new('Boris') | ||
human.age = 35 | ||
expect(human.can_drink?).to be true | ||
end | ||
|
||
it 'returns false if human is underage' do | ||
human = Human.new('Boris Jr') | ||
human.age = 14 | ||
expect(human.can_drink?).to be false | ||
|
||
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. try not to leave blank lines between the |
||
end | ||
|
||
it 'checks the drinking age for a given country' do | ||
human = Human.new('Garfield') | ||
human.age = 18 | ||
expect(human.can_drink? 'Australia').to be true | ||
expect(human.can_drink? 'United States').to be false | ||
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. can you add a test to see what happens when we use an address that does not match one in our list |
||
end | ||
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. can you add another test and not set age and see what happens |
||
end | ||
|
||
|
||
it 'play area' do | ||
puts Human.new('Caitlin').name | ||
end | ||
end | ||
|
||
|
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.
great foresight here... Only small suggestion, this would be better to put in another file (or in Rails we would of had it in a DB table) to reduce the noise in the model
In this case it might be better to make this another class that you can ask for drinking_ages (as per comment below in specs). We can discuss this further next week