Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
16 changes: 15 additions & 1 deletion animal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ def initialize(name, type, age)
end

def old?
age > 3
age.to_i > 3
end

def respond
if @type == "cat"
"Meow!"
elsif @type == "dog"
"Woof!"
elsif @type == "cow"
"Moo!"
elsif @type == "fox"
"Yip!"
else
"Me Tarzan!"
end
end
end
36 changes: 35 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
#Create your feature here
Feature: Demonstrate how the clientele will respond

Scenario: Cat is called Bob
Given a "cat" named "Bob" that is 10 years old
Then they will respond to "Bob"

Scenario: Cat is 6 years old and old
Given a "cat" named "Sally" that is 6 years old
Then they are 6 years old
And they are old

Scenario: Cat is chatty
Given a "cat"
Then it is confirmed a "cat"
And the "cat" responds with "Meow!"

Scenario: Dog is chatty
Given a "dog"
Then it is confirmed a "dog"
And the "dog" responds with "Woof!"

Scenario: Cow is chatty
Given a "cow"
Then it is confirmed a "cow"
And the "cow" responds with "Moo!"

Scenario: Fox is chatty
Given a "fox"
Then it is confirmed a "fox"
And the "fox" responds with "Yip!"

Scenario: Not your traditional animal
Given a "human"
Then it is confirmed a "human"
And the "human" responds with "Me Tarzan!"
33 changes: 32 additions & 1 deletion features/step_definitions/animal_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
#Delete this comment, here is where you should write your step defs
Given (/^a "(.*?)"$/) do |type|
@animal=Animal.new('Spot', type, 5)
end

Given (/^a "(.*?)" named "(.*?)" that is (\d+) years old$/) do |type, name, age|
@animal=Animal.new(name, type, age)
end

#old check
Then (/^they are old$/) do
expect(@animal.old?).to eq true
end

#animal response check
Then(/^the "(.*?)" responds with "(.*?)"$/) do |type, response|
expect(@animal.respond).to eq response
end

#name check
Then(/^they will respond to "(.*?)"/) do |name|
expect(@animal.name).to eq name
end

#age check
Then(/^they are (\d+) years old/) do |age|
expect(@animal.age).to eq age
end

#type check
Then (/^it is confirmed a "(.*?)"$/) do |type|
expect(@animal.type == type)
end
2 changes: 1 addition & 1 deletion features/step_definitions/greeter_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
end

When(/^older than (\d+)$/) do |arg1|
expect(@animal.old?).to be true
expect(@animal.old?).to be true
end

When(/^I verify it is a "(.*?)"$/) do |type|
Expand Down