Working my way back out to the features, I hit a snag. The main application spec exercises the new
wiki
helper method with nil
input. The result is an error. I need to describe how the helper should work in such a situation:it "should return an empty string if called with nil" doMaking this example pass is a simple matter of using an empty string if nil is supplied to the
wiki(nil).should == ""
end
wiki
helper:def wiki(original)(commit)
text = (original || '').dup
text.gsub!(/\b(\d+)F/, "\\1° F")
text.gsub!(/\[kid:(\w+)\]/m) { |kid| kid_nicknames[$1] }
text.gsub!(/\[recipe:(\S+)\]/m) { |r| recipe_link($1) }
RedCloth.new(text).to_html
end
Back Out to the Feature
Running the feature that started this helper effort reveals that I need to check off two more steps in the scenario:cstrom@jaynestown:~/repos/eee-code$ cucumber features/recipe_details.feature \Those pending steps can be implemented with matchers similar to:
-n -s "Viewing summary and recipe instructions"
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 summary and recipe instructions
Given a recipe for Curried Shrimp
When I view the recipe
Then I should a nice summary of the dish
And I should see detailed, easy-to-read instructions
1 scenario
2 steps passed
2 steps pending (2 with no step definition)
You can use these snippets to implement pending steps which have no step definition:
Then /^I should a nice summary of the dish$/ do
end
Then /^I should see detailed, easy\-to\-read instructions$/ do
end
Then /^I should a nice summary of the dish$/ do(commit)
response.should have_selector("p", :content => "This dish is yummy") do |p|
p.should have_selector("strong", :content => "yummy")
end
end
Then /^I should see detailed, easy\-to\-read instructions$/ do
response.should have_selector("p", :content => "While the shrimp are defrosting, we chop the vegetables.")
end
No comments:
Post a Comment