From c869f1ef73ce31314da5020aead738c31b05ec88 Mon Sep 17 00:00:00 2001 From: Cara Kane Date: Mon, 14 May 2018 13:06:10 -0400 Subject: [PATCH] finished challenge --- features/animal.feature | 20 ++++++++++++++++++ features/step_definitions/animal_steps.rb | 25 ++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/features/animal.feature b/features/animal.feature index aa25af6..f589632 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -1 +1,21 @@ #Create your feature here +#The hotel manager wants the script to keep track of the name, type and age of every animal +#Test the Animal object and ensure that it has the right output for its reader methods name, +#type, age, old? + +Feature: Animal + I want my animal variables to be accessible + + Scenario: Old Dog + Given an Animal + Then I check it is a "dog" + And I verify it has an "age" + And I see if it has a "name" + And I see if it is old + + Scenario: Young Fish + Given an Animal + Then I check it is a "fish" + And I verify it has an "age" + And I see if it has a "name" + And I see if it is old \ No newline at end of file diff --git a/features/step_definitions/animal_steps.rb b/features/step_definitions/animal_steps.rb index 324ff13..5f597a8 100644 --- a/features/step_definitions/animal_steps.rb +++ b/features/step_definitions/animal_steps.rb @@ -1 +1,24 @@ -#Delete this comment, here is where you should write your step defs +Given(/^an Animal$/) do + @animal = Animal.new('Lucy', 'dog', 4) + @animal1 = Animal.new('Robert', 'fish', 2) + end + + Then(/^I check it is a "(.*?)"$/) do |arg1| + expect(@animal.type).to eq "dog" + expect(@animal1.type).to eq "fish" + end + + Then(/^I verify it has an "(.*?)"$/) do |arg1| + expect(@animal.age).to eq 4 + expect(@animal1.age).to eq 2 + end + + Then(/^I see if it has a "(.*?)"$/) do |arg1| + expect(@animal.name).to eq "Lucy" + expect(@animal1.name).to eq "Robert" + end + + Then(/^I see if it is old$/) do + expect(@animal.old?).to eq true + expect(@animal1.old?).to eq false + end \ No newline at end of file