From 19d41c6de33554949c0f9572791470517c93b00d Mon Sep 17 00:00:00 2001 From: Matthew Crocco Date: Mon, 5 Jun 2017 23:10:30 -0400 Subject: [PATCH] Solution commit --- features/animal.feature | 18 ++++++++++++++++- features/step_definitions/animal_steps.rb | 24 ++++++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/features/animal.feature b/features/animal.feature index aa25af6..6f5eff7 100644 --- a/features/animal.feature +++ b/features/animal.feature @@ -1 +1,17 @@ -#Create your feature here +Feature: Animal + For the Classy Hotel to track their animal clientele + they use a client's name, type and age + + Scenario: Coolio the Capybara + Given a capybara named 'Coolio' who is 10 years of age + Then it should be tracked as a capybara + And it should be named 'Coolio' + And it should be 10 years old + And it should be considered old + + Scenario: Frank the Fox + Given a fox named 'Frank' who is 2 years of age + Then it should be tracked as a fox + And it should be named 'Frank' + And it should be 2 years old + And it should be considered 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..1585aed 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 (\w+) named '(.+)' who is (\d+) years of age/) do |type, name, age| + @animal = Animal.new(name, type, age.to_i) +end + +Then(/^it should be tracked as a (\w+)/) do |type| + expect(@animal.type).to eq type +end + +Then(/^it should be named '(\w+)'/) do |name| + expect(@animal.name).to eq name +end + +Then(/^it should be (\d+) years old/) do |age| + expect(@animal.age).to eq age.to_i +end + +Then(/^it should be considered (young|old)/) do |age_category| + if age_category == 'young' + expect(@animal).not_to be_old + else + expect(@animal).to be_old + end +end \ No newline at end of file