With all of my inside / view specs passing, I continue my chain by moving back out to cucumber:
cstrom@jaynestown:~/repos/eee-code$ cucumber features/recipe_details.feature -n \Implementing this and the next steps is as easy as this:
-s "Viewing a recipe with non-active prep time"
Feature: Recipe Details
So that I can accurately reproduce a recipe at home
As a web user
I want to be able to easily recognize important details
Scenario: Viewing a recipe with non-active prep time
Given a recipe for Crockpot Lentil Andouille Soup
When I view the recipe
Then I should see 15 minutes of prep time
And I should see that it requires 5 hours of non-active cook time
Pending Notes:
Then /^I should see 15 minutes of prep time$/ (TODO) # features/step_definitions/recipe_details.rb:67
1 scenario
2 steps passed
2 steps pending (1 with no step definition)
Then /^I should see 15 minutes of prep time$/ do(commit)
response.should contain("Preparation Time: 15 minutes")
end
Then /^I should see that it requires 5 hours of non\-active cook time$/ do
response.should contain("Inactive Time: 5 hours")
end
Up next is the "Viewing a list of tools used to prepare the recipe" scenario:
Feature: Recipe DetailsTo implement the Given step, I again copy and paste other Given steps, this time adding the legacy tools data structure:
So that I can accurately reproduce a recipe at home
As a web user
I want to be able to easily recognize important details
Scenario: Viewing a list of tools used to prepare the recipe
Given a recipe for Chicken Noodle Soup
When I view the recipe
Then I should see that it requires a bowl, a colander, a cutting board, a pot and a skimmer to prepare
1 scenario
1 step skipped
2 steps pending (2 with no step definition)
You can use these snippets to implement pending steps which have no step definition:
Given /^a recipe for Chicken Noodle Soup$/ do
end
Then /^I should see that it requires a bowl, a colander, a cutting board, a pot and a skimmer to prepare$/ do
end
recipe = {The ASIN is a unique code that Amazon.com uses to identify its products. It is used on the legacy EEE Cooks site to illustrate and to make a little money to support the site via referral fees. I honestly don't recall the need for the
:title => @title,
:date => @date,
:tools => [
{
"title" => "Bowl",
"asin" => nil,
"amazon_title" => nil
},
{
"title" => "Colander",
"asin" => nil,
"amazon_title" => nil
},
{
"title" => "Cutting Board",
"asin" => nil,
"amazon_title" => nil
},
{
"title" => "Pot",
"asin" => nil,
"amazon_title" => nil
},
{
"title" => "Skimmer",
"asin" => nil,
"amazon_title" => nil
},
]
}
amazon_title
attribute. I plan to treat it as expendable.(commit)
Now it is time to move back into the view specs. I finish with two tools in the
before(:each)
block—one to implement the simplest possible way (hard coding) and the other to force a dynamic solution. The specs are:context "a recipe requiring a colander and a pot" doAs with the ingredient preparations, I also need a boundary condition case for when there are no tools used in a recipe. The boundary condition is represented as:
before(:each) do
colander = {
'title' => "Colander",
'asin' => "ASIN-1234"
}
pot = {
'title' => "Pot",
'asin' => "ASIN-5678"
}
@recipe['tools'] = [colander, pot]
render("views/recipe.haml")
end
it "should contain a link to the colander on Amazon" do
response.should have_selector("a", :content => "Colander",
:href => "http://www.amazon.com/exec/obidos/ASIN/ASIN-1234/eeecooks-20")
end
it "should contain a link to the pot on Amazon" do
response.should have_selector("a", :content => "Pot",
:href => "http://www.amazon.com/exec/obidos/ASIN/ASIN-5678/eeecooks-20")
end
end
context "a recipe with no tools or appliances" doFinally, the Haml code that makes this pass is:
before(:each) do
@recipe[:tools] = nil
end
it "should not render an ingredient preparations" do
render("views/recipe.haml")
response.should_not have_selector(".eee-recipe-tools")
end
end
- if @recipe['tools'](commit)
.eee-recipe-tools
%h2= "Tools and Appliances Used"
%ul
- @recipe['tools'].each do |tool|
%li
%a{:href => amazon_url(tool['asin'])}
= tool['title']
Completing the circle, I work my way back outside to define the
Then I should see that it requires a Bowl, a Colander, a Cutting Board, a Pot and a Skimmer to prepare
step:Then /^I should see that it requires (.+) to prepare$/ do |tool_list|I take the string list of tools and split on commas and the word "and". The RegExp grouping that is needed to accomplish this has the unfortunate side-effect of including the commas and "ands" in the resulting array, so they need to be explicitly rejected. Finally, the response is checked to verify that it contains each tool.
tools = tool_list.
split(/\s*(,|and)\s*/).
reject{|str| str == "," || str == "and"}
tools.each do |tool|
response.should contain(tool.sub(/an? /, ''))
end
end
(commit)
And that is it! I completed working my way outside of one scenario and then in-and-out for another scenario all in one night. I am definitely picking up speed. It will be time for a VPS decision real soon now.
I really like the way you write the post and help us with the information. Thank you for sharing this post. Please read my blogs too.
ReplyDeleteaviano copper protector review
creaclip review
peeps by carbon klean review
photostick reviews
tiki tunes review