diff --git a/features/.DS_Store b/features/.DS_Store new file mode 100644 index 0000000..cdfa1ab Binary files /dev/null and b/features/.DS_Store differ diff --git a/features/animal.feature b/features/animal.feature index aa25af6..cdfccca 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -1 +1,10 @@ -#Create your feature here +Feature: Track animals + keep the track of name, type and age of every animal + Based on the age determine whether the animal is old or not + +Scenario: An animal + Given Animal is a lion named Leo who is 5 years old + Then name of the animal is "Leo" + And its type is lion + And it is 5 years old + And the animal is old diff --git a/features/step_definitions/animal_steps.rb b/features/step_definitions/animal_steps.rb index 324ff13..3a60dc2 100644 --- a/features/step_definitions/animal_steps.rb +++ b/features/step_definitions/animal_steps.rb @@ -1 +1,21 @@ -#Delete this comment, here is where you should write your step defs + +Given (/^Animal is a (.*?) named (.*?) who is (\d+) years old$/) do |type, name, age| + @animal = Animal.new(name, type, age.to_i) +end + +Then(/^name of the animal is "(.*?)"$/) do |arg1| + #name of the animal is "Leo" + expect(@animal.name).to eq arg1 +end + +Then(/^its type is (.*?)$/) do |type| + expect(@animal.type).to eq type +end + +Then(/^it is (\d+) years old$/) do |age| + expect(@animal.age).to eq age.to_i +end + +Then(/^the animal is old$/) do + expect(@animal.old?).to be true +end