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 #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
#Create your feature here
Feature: Animal
For the Classy Hotel to track their animal clientele
they use a client's name, type and age

Scenario: Coolio the Capybara
Given a capybara named 'Coolio' who is 10 years of age
Then it should be tracked as a capybara
And it should be named 'Coolio'
And it should be 10 years old
And it should be considered old

Scenario: Frank the Fox
Given a fox named 'Frank' who is 2 years of age
Then it should be tracked as a fox
And it should be named 'Frank'
And it should be 2 years old
And it should be considered young
24 changes: 23 additions & 1 deletion features/step_definitions/animal_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
#Delete this comment, here is where you should write your step defs
Given(/^a (\w+) named '(.+)' who is (\d+) years of age/) do |type, name, age|
@animal = Animal.new(name, type, age.to_i)
end

Then(/^it should be tracked as a (\w+)/) do |type|
expect(@animal.type).to eq type
end

Then(/^it should be named '(\w+)'/) do |name|
expect(@animal.name).to eq name
end

Then(/^it should be (\d+) years old/) do |age|
expect(@animal.age).to eq age.to_i
end

Then(/^it should be considered (young|old)/) do |age_category|
if age_category == 'young'
expect(@animal).not_to be_old
else
expect(@animal).to be_old
end
end