diff --git a/features/.DS_Store b/features/.DS_Store new file mode 100644 index 0000000..120bb13 Binary files /dev/null and b/features/.DS_Store differ diff --git a/features/animal.feature b/features/animal.feature index aa25af6..fc67240 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -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" \ No newline at end of file diff --git a/features/step_definitions/animal_steps.rb b/features/step_definitions/animal_steps.rb index 324ff13..e0de77e 100644 --- a/features/step_definitions/animal_steps.rb +++ b/features/step_definitions/animal_steps.rb @@ -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 \ No newline at end of file