Having cleared out the first spec failures last night, I get started implementing the first scenario in the Recipe Details Cucumber story:
Feature: Recipe DetailsMostly following along with what I discovered in my Cucumber / Sinatra spike, I implement the Given and When steps as:
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 several ingredients
Given a recipe for Buttermilk Chocolate Chip Pancakes
When I view the recipe
Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"
And I should see an ingredient of "¼ teaspoons salt"
And I should see an ingredient of "chocolate chips (Nestle Tollhouse)"
Given /^a recipe for Buttermilk Chocolate Chip Pancakes$/ doThe next pending step is reported as:
@date = Date.new(2009, 03, 24)
@title = "Buttermilk Chocolate Chip Pancakes"
@permalink = @date.to_s + "-" + @title.downcase.gsub(/\W/, '-')
RestClient.put "#{@@db}/#{@permalink}",
{ :title => @title,
:date => @date }.to_json,
:content_type => 'application/json'
end
When /^I view the recipe$/ do
visit("/recipes/#{@permalink}")
end
You can use these snippets to implement pending steps which have no step definition:Implementing this as a simple response-should-contain:
Then /^I should see an ingredient of "1 cup of all\-purpose, unbleached flour"$/ do
end
Then /^I should see an ingredient of "(.+)"$/ do |ingredient|When this is run, I get the following error:
response.should contain(ingredient)
end
Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"This simply means that the requested resource has not been defined in the Sinatra app. To get rid of the warning, define an empty resource:
expected the following element's content to include "1 cup of all-purpose, unbleached flour":
Not Found (Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/recipe_details.rb:17:in `Then /^I should see an ingredient of "(.+)"$/'
features/recipe_details.feature:11:in `Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"'
get '/recipes/:permalink' doRe-running the spec changes the error to:
end
Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"We have gone from a Not Found error to an expectation not met error. Progress!
expected the following element's content to include "1 cup of all-purpose, unbleached flour": (Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/recipe_details.rb:17:in `Then /^I should see an ingredient of "(.+)"$/'
features/recipe_details.feature:11:in `Then I should see an ingredient of "1 cup of all-purpose, unbleached flour"'
At this point, I need to move from the outside in by dropping down into RSpec. Tomorrow...
No comments:
Post a Comment