diff --git a/features/animal.feature b/features/animal.feature index aa25af6..dda2014 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -1 +1,11 @@ -#Create your feature here +Feature: Animal + In order to properly identify animals + An Animal should have name, type, and age + Based on age, can tell if it's old + +Scenario: cat + Given a cat called Tom who is 2 years old + Then name should be Tom + And is of type 'cat' + And be of age 2 + Then should not be old diff --git a/features/step_definitions/animal_steps.rb b/features/step_definitions/animal_steps.rb index 324ff13..2d9eee9 100644 --- a/features/step_definitions/animal_steps.rb +++ b/features/step_definitions/animal_steps.rb @@ -1 +1,19 @@ -#Delete this comment, here is where you should write your step defs +Given(/^a (.*?) called (.*?) who is (\d+) years old$/) do |type, name, age| + @animal = Animal.new(name, type, age.to_i) +end + +Then(/^name should be (.*?)$/) do |name| + expect(@animal.name).to eq name +end + +And(/^is of type '(.*?)'$/) do |type| + expect(@animal.type).to eq type +end + +And(/^be of age (\d+)$/) do |age| + expect(@animal.age).to eq age.to_i +end + +Then(/^should not be old$/) do + expect(@animal.old?).to be false +end