Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

complete challenge- not sure how to run the cucumber tests, but the s… #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
13 changes: 11 additions & 2 deletions animal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ def initialize(name, type, age)
@age = age
end

def old?
age > 3
def feed
case type
when "cat"
"Here is some fresh salmon."
when "dog"
"Here is some prime rib."
when "bird"
"Here are some tasty seeds."
else
"We do not know how to feed you. Please alert the front desk."
end
end
end
10 changes: 9 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
#Create your feature here
Feature: Room Service
In order to properly nourish our animals
As a cat
I want to be fed fish

Scenario: Cat
Given an animal
When I verify she is a "cat"
Then I should give her salmon
12 changes: 11 additions & 1 deletion features/step_definitions/animal_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
#Delete this comment, here is where you should write your step defs
Given(/^an animal$/) do
@animal = Animal.new('Lucy', 'cat', 4)
end

When(/^I verify she is a "(.*?)"$/) do |type|
expect(@animal.type).to eq type
end

Then(/^I should give her (.*?)$/) do |title|
expect(@animal.feed).to include title
end
9 changes: 4 additions & 5 deletions features/step_definitions/greeter_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
end

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

When(/^I verify it is a "(.*?)"$/) do |type|
greeter = Greeter.new(@animal)
expect(greeter.animal.type).to eq type
@greeter = Greeter.new(@animal)
expect(@greeter.send(type + '?')).to be true
end

Then(/^I should see "(.*?)"$/) do |title|
greeter = Greeter.new(@animal)
expect(greeter.greet).to eq title
expect(@greeter.greet).to eq title
end
2 changes: 1 addition & 1 deletion greeter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def cat?
end

def greet
if cat?
if cat? && animal.age > 3
"Mr Cat"
else
"We don't know how to greet #{animal.name}"
Expand Down