Having deployed another feature to the beta site, it is time to take stock again of where I am at:
cstrom@jaynestown:~/repos/eee-code$ cucumber features -iNot too shabby.
...
37 scenarios (5 undefined, 32 passed)
333 steps (13 skipped, 22 undefined, 298 passed)
0m37.909s
The 5 undefined Cucumber scenarios are contained in two features:
Feature: Alternate preparations for recipesIf I were starting from scratch, I would choose to implement the "Alternate" recipes feature first. Presenting a list of alternate preparations is a nice means of engaging users and encouraging them to explore the site.
As a user curious about a recipe
I want to see a list of similar recipes
So that I can find a recipe that matches my tastes or ingredients on hand
Feature: Updating recipes in our cookbook
As an author
I want to mark recipes as replacing old one
So that I can record improvements and retain previous attempts for reference
I am replacing a legacy site however, so I am more interested in suppressing recipes that have been updated. Some of the early recipes in our cookbook were... rough. I would truly hate to replace the legacy site without including a warning on such recipes that a better recipe now exists.
The "Updating recipes in our cookbook" feature has three scenarios:
Scenario: No previous or next version of a recipeThe first scenario should work now, but some of the steps in there can be re-used in subsequent steps—making it worthwhile to implement:
Scenario: A previous version of the recipe
Scenario: Searching for a recipe with an update
Scenario: No previous or next version of a recipeI can define the first, given-a-pancake step, as:
Given a "Buttermilk Pancake" recipe with "buttermilk" in it
When I view the recipe
Then I should not see previous versions of the recipe
And I should not see updated versions of the recipe
Given /^a "([^\"]*)" recipe with "([^\"]*)" in it$/ do |title, ingredient|There is nothing new in there—it is very similar to the step defined in earlier scenarios describing details of the various recipe pages. In this case it is modified to expect an ingredient in the text so that the recipe pages can be tested for it. The when-i-visit-the-page step was already defined, so I need only to define the last two steps in the scenario.
@date = Date.new(2009, 9, 5)
@title = title
@permalink = @date.to_s + "-" + @title.downcase.gsub(/\W/, '-')
recipe = {
:title => @title,
:date => @date,
:preparations => [{'ingredient' => {'name' => ingredient}}]
}
RestClient.put "#{@@db}/#{@permalink}",
recipe.to_json,
:content_type => 'application/json'
end
In the legacy site, recipes that update previous entries in the cookbook contain a note similar to:
For the next step, I am checking that the current recipe is not an update, so I do not want to see any text to the effect:
Then /^I should not see previous versions of the recipe$/ doSimilarly, when a recipe has been updated on the legacy site, it contains text like this:
response.should_not contain 'This is an update of a previous recipe'
end
The last step in this "happy path" scenario of no update, then, should be:
Then /^I should not see updated versions of the recipe$/ doAnd, without doing a lick of "real" work, I have my scenario working:
response.should_not contain 'This recipe has been updated'
end
cstrom@jaynestown:~/repos/eee-code$ cucumber features/recipe_replacement.feature:7Besides getting a simple scenario passing, I not have have lotsa blue (defined, but not yet reached steps) in the other two scenarios in this feature:
Sinatra::Test is deprecated; use Rack::Test instead.
Feature: Updating recipes in our cookbook
As an author
I want to mark recipes as replacing old one
So that I can record improvements and retain previous attempts for reference
Scenario: No previous or next version of a recipe # features/recipe_replacement.feature:7
Given a "Buttermilk Pancake" recipe with "buttermilk" in it # features/step_definitions/recipe_replacement.rb:1
When I view the recipe # features/step_definitions/recipe_details.rb:155
Then I should not see previous versions of the recipe # features/step_definitions/recipe_replacement.rb:17
And I should not see updated versions of the recipe # features/step_definitions/recipe_replacement.rb:21
1 scenario (1 passed)
4 steps (4 passed)
0m0.636s
Most importantly, I have begun noodling through this feature. Tomorrow, actual work begins.
No comments:
Post a Comment