Skip to content
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
Binary file added features/.DS_Store
Binary file not shown.
19 changes: 18 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
#Create your feature here
Feature: Animal
In order to distinguish animals
I want to know a name, type and an age
And be able to differentiate between old and young

Scenario: Cat
Given a "Cat" named "Admiral" that's "4" years old
When asking "Admiral" it's name
And asking the "Cat" it's type
And asking the age "4" animal it's age
Then I should see it is "old"

Scenario: Dog
Given a "Dog" named "Geoff" that's "2" years old
When asking "Geoff" it's name
And asking the "Dog" it's type
And asking the age "2" animal it's age
Then I should see it is "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 "(.*?)" named "(.*?)" that's "(.*?)" years old$/) do |type, name, age|
@animal = Animal.new(name, type, age.to_i)
end

When(/^asking "(.*?)" it's name$/) do |arg1|
expect(@animal.name).to eq(arg1)
end

When(/^asking the "(.*?)" it's type$/) do |arg1|
expect(@animal.type).to eq(arg1)
end

When(/^asking the age "(.*?)" animal it's age$/) do |arg1|
expect(@animal.age).to eq(arg1.to_i)
end

Then(/^I should see it is "(.*?)"$/) do |arg1|
if arg1 == "old"
expect(@animal.old?).to be true
else
expect(@animal.old?).to be false
end
end