From 030153b449c8ce7eefd9c5c8b0485015774440e6 Mon Sep 17 00:00:00 2001 From: Lucas Nestor Date: Fri, 11 May 2018 14:37:56 -0400 Subject: [PATCH] Complete challenge --- features/animal.feature | 15 +++++++++++++- features/step_definitions/animal_steps.rb | 24 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/features/animal.feature b/features/animal.feature index aa25af6..e4169d5 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -1 +1,14 @@ -#Create your feature here +Feature: Animal + Scenario: Old Cat + Given a "cat" named "Bob" that is 5 years old + Then it should be named "Bob" + And it should be a "cat" + And it should be 5 years old + And it should be considered old + + Scenario: Yound Dog + Given a "dog" named "Winny" that is 2 years old + Then it should be named "Winny" + And it should be a "dog" + And it should be 2 years old + And it should not be considered old diff --git a/features/step_definitions/animal_steps.rb b/features/step_definitions/animal_steps.rb index 324ff13..219d296 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 is (\d+) years old$/) do |type, name, age| + @animal = Animal.new(name, type, age.to_i) +end + +Then(/^it should be named "(.*?)"$/) do |name| + expect(@animal.name).to eq name +end + +Then(/^it should be a "(.*?)"$/) do |type| + expect(@animal.type).to eq type +end + +Then(/^it should be (\d+) years old$/) do |age| + expect(@animal.age).to eq age.to_i +end + +Then(/^it should be considered old$/) do + expect(@animal.old?).to be_truthy +end + +Then(/^it should not be considered old$/) do + expect(@animal.old?).to be_falsey +end