Before moving on to "real" work, I run all of my tests only to find that I have several errors. There are many errors in the
meal.haml_spec.rb
specification:11)All eleven errors are caused by the inclusion of the
NoMethodError in 'meal.haml should wikify the meal's description'
undefined method `[]' for nil:NilClass
./helpers.rb:18:in `recipe_category_link'
(haml):39:in `any?'
./helpers.rb:17:in `each'
./helpers.rb:17:in `any?'
./helpers.rb:17:in `recipe_category_link'
(haml):2:in `render'
/home/cstrom/.gem/ruby/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `render'
/home/cstrom/.gem/ruby/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `instance_eval'
/home/cstrom/.gem/ruby/1.8/gems/haml-2.0.9/lib/haml/engine.rb:149:in `render'
/home/cstrom/repos/eee-code/spec/spec_helper.rb:27:in `render'
./spec/views/meal.haml_spec.rb:86:
recipe_category_link
helper last night. I am not able to stub out the method, so I seed some dummy data in the before(:each)
block to eliminate the errors:assigns[:recipes] = []This prevents the
recipe_category_link
from acting upon a nil
@recipes
array when building the category links:%ul#eee-categoriesNext up, it is back to the Cucumber scenario. Specifically, I need to mark a few scenario steps as complete in the navigation-from-the-homepage Cucumber scenario. Yesterday, I was able to verify that a user could navigate from the homepage to a recent meal. I also ensured that site-wide categories were displaying on the same meal page.
%li= recipe_category_link(@recipes, 'Italian')
%li= recipe_category_link(@recipes, 'Asian')
...
Now, I need to ensure that the user can navigate from the meal down to a recipe listed on the menu. Cucumber tells me that I can implement the missing steps with:
When /^I click on the recipe in the menu$/ doAs mentioned, the scenario so far involves clicking on the most recently prepared meal, then clicking on the recipe on that meal's menu. The meals created for this scenario have titles: "Meal 0", "Meal 1", "Meal 2", etc. In turn, the recipes for each meal are named simply: "Recipe for Meal 0", "Recipe for Meal 1", "Recipe for Meal 2", etc. So, to click on the recipe for the first meal, I need to look for a link to "Recipe for Meal 0":
pending
end
Then /^I should see the recipe page$/ do
pending
end
When /^I click on the recipe in the menu$/ doSimilarly, to verify that I am on the appropriate recipe page, I check the
click_link "Recipe for Meal 0"
end
<h1>
tag:Then /^I should see the recipe page$/ doThe next step in the scenario, that the Italian category should be highlighted for this Italian recipe, was implemented last night. The step was written for the meal (the meal is Italian because it has an Italian recipe on the menu), but applies to category links on the recipe page just as it does on the meal page.
response.should have_selector("h1",
:content => "Recipe for Meal 0")
end
And just like that, I am done with 14 of the 21 steps in the scenario:
Before moving onto the next steps, I think there are some DRY violations in the category links that I need to address. Tomorrow.
No comments:
Post a Comment