Now that I have the simple feedback Cucumber scenario working, I need to complete two more scenarios:
Scenario: Give feedback to the authors on a yummy mealActually, I need to define these scenarios, before I can implement them. I would much prefer to re-use steps rather than adding new ones, so I
Scenario: Send compliments to the chef on a delicious recipe
grep
through my Given
steps to see what I might use:cstrom@jaynestown:~/repos/eee-code$ grep Given features/step_definitions/*The date does not really matter, but I opt for the former since it reads OK in the scenario. After picking and choosing the remainder of the scenario steps, I end up with:
features/step_definitions/meal_details.rb:Given /^a "([^\"]*)" meal enjoyed [io]n (.+)$/ do |title, date_str|
features/step_definitions/meal_details.rb:Given /^a "([^\"]*)" meal with the "([^\"]*)" recipe on the menu$/ do |title, recipe_title|
…
Scenario: Give feedback to the authors on a yummy mealAnd something similar for the recipe feedback scenario:
Given a "Yummy" meal enjoyed on 2009-06-27
When I view the "Yummy" meal
And I click "Send us feedback on this meal"
Then I should see a feedback form
And I should see a subject of "[Meal] Yummy"
Scenario: Send compliments to the chef on a delicious recipeOne other thing that ought to happen in both scenarios is that the recipe/meal should supply the feedback form with its URL so that the email that we receive includes the URL. We prefer having the URL so that we can click it to fix any mistakes. I do not include that in the scenario since it is written from the user's perspective—mixing perspectives can lead to unnecessary conflicts. Instead I will try to remember to do this as I work inside the code.
Given a "Yummy" recipe from 2009-06-27
When I view the recipe
And I click "Send us feedback on this recipe"
Then I should see a feedback form
And I should see a subject of "[Recipe] Yummy"
First up, I run the scenario to see what else needs to be implemented:
cstrom@jaynestown:~/repos/eee-code$ cucumber features -n \Not too bad, I just need to get two step defined.
-s "Give feedback to the authors on a yummy meal"
Sinatra::Test is deprecated; use Rack::Test instead.
Feature: Site
So that I may explore many wonderful recipes and see the meals in which they were served
As someone interested in cooking
I want to be able to easily explore this awesome site
Scenario: Give feedback to the authors on a yummy meal
Given a "Yummy" meal enjoyed on 2009-06-27
When I view the "Yummy" meal
And I click "Send us feedback on this meal"
Could not find link with text or title or id "Send us feedback on this meal" (Webrat::NotFoundError)
features/site.feature:60:in `And I click "Send us feedback on this meal"'
Then I should see a feedback form
And I should see a subject of "[Meal] Yummy"
1 scenario
1 failed step
1 skipped step
1 undefined step
2 passed steps
You can implement step definitions for missing steps with these snippets:
Then /^I should see a subject of "([^\"]*)"$/ do |arg1|
pending
end
To drive the meal template's inclusion of the subject and URL I just this rather ugly bit of RSpec:
it "should include the recipe's URL in the feedback link" doI need to escape the URL and subject, so the example needs to account for this. Once that is implemented, I have only one more step to go:
render("/views/meal.haml")
response.should have_selector("a",
:href => "/feedback?url=http%3A%2F%2Fexample.org%2Frecipe-1&subject=%5BMeal%5D+Meal+Title",
:content => "Send us feedback on this meal")
end
I will pick up tomorrow with that last step and doing the same for recipes.
No comments:
Post a Comment