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

Add cucumber steps and feature for animal #42

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion animal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ def initialize(name, type, age)
end

def old?
age > 3
@age > 3
end
end
13 changes: 12 additions & 1 deletion features/animal.feature
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
#Create your feature here
Feature: Animal
In order to properly track animals
An animal must have a name, type and age
And can determine if it's old

Scenario: Bear
Given a 3 year old Bear named Charles
Then it should have the name Charles
And have the species be Bear
And be 3 years old
And is not old

4 changes: 2 additions & 2 deletions features/greeter.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Feature: Greeter
In order to properly address senior animals
As a old cat
As an old cat
I want to be greeted as 'Mr Cat'

Scenario: Cat
Given a animal
Given an animal
When older than 3
And I verify it is a "cat"
Then I should see "Mr Cat"
20 changes: 19 additions & 1 deletion features/step_definitions/animal_steps.rb
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
#Delete this comment, here is where you should write your step defs
Given(/^a (\d+) year old (.*?) named (.*?)$/) do |age, species, name|
@bear = Animal.new(name, species, age.to_i)
end

Then(/^it should have the name (.*?)$/) do |name|
expect(@bear.name).to eq name
end

And(/^have the species be (.*?)$/) do |species|
expect(@bear.type).to eq species
end

And(/^be (\d+) years old$/) do |arg1|
expect(@bear.age).to eq arg1.to_i
end

And(/^is not old$/) do
expect(@bear.old?).to be false
end
2 changes: 1 addition & 1 deletion features/step_definitions/greeter_steps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Given(/^a animal$/) do
Given(/^an animal$/) do
@animal = Animal.new('Lucy', 'cat', 4)
end

Expand Down