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
23 changes: 22 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
#Create your feature here
Feature: Animal
Animals should properly return their attributes.

Scenario: Name
Given an animal named Lucy
Then the animal should be named Lucy

Scenario: Type
Given an animal that is a cat
Then the animal should be a cat

Scenario: Age
Given an animal that is 3 years old
Then the animal should be 3 years old

Scenario: Old
Given an animal that is 5 years old
Then the animal should be old

Scenario: Young
Given an animal that is 2 years old
Then the animal should be young
32 changes: 31 additions & 1 deletion features/step_definitions/animal_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
#Delete this comment, here is where you should write your step defs
Given(/^an animal named (.*?)$/) do |name|
@animal = Animal.new(name, 'cat', 4)
end

Given(/^an animal that is a (.*?)$/) do |type|
@animal = Animal.new('george', type, 4)
end

Given(/^an animal that is (\d+) years old$/) do |age|
@animal = Animal.new('george', 'cat', age.to_i)
end

Then(/^the animal should be a (.*?)$/) do |type|
expect(@animal.type).to eq type
end

Then(/^the animal should be named (.*?)$/) do |name|
expect(@animal.name).to eq name
end

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

Then(/^the animal should be old$/) do
expect(@animal.old?).to be true
end

Then(/^the animal should be young$/) do
expect(@animal.old?).to be false
end
2 changes: 1 addition & 1 deletion features/step_definitions/greeter_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
end

When(/^older than (\d+)$/) do |arg1|
expect(@animal.old?).to be true
expect(@animal.old?).to be true
end

When(/^I verify it is a "(.*?)"$/) do |type|
Expand Down