Realizing that I had overlooked recipe summary and instructions, I get started on them tonight. The feature scenario:
Scenario: Viewing summary and recipe instructionsThe inside view specs are straight-forward:
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
it "should display the recipe's summary" doThe not-so-trivial part of working inside the guts of the application is that
self.stub!(:wiki).and_return("wiki #{@summary}")
render("/views/recipe.haml")
response.should have_selector("#eee-summary",
:content => "wiki #{@summary}")
end
it "should display the recipe's instructions" do
self.stub!(:wiki).and_return("wiki #{@instructions}")
render("/views/recipe.haml")
response.should have_selector("#eee-instructions",
:content => "wiki #{@instructions}")
end
wiki
helper method. In addition to textilizing text, it performs various domain-specific clean-up such as converting 250F to 250° F, replacing recipe URIs with linked titles and replacing our kids names with nicknames.Happily, I spent quite a bit of time getting helpers into controller specs. Even better, that work makes direct helper specifications trivial:
require File.expand_path(File.dirname(__FILE__) + '/spec_helper' )A trivial implementation of the
describe "wiki" do
it "should return simple text as unaltered text" do
wiki("bob").should == "bob"
end
it "should convert textile to HTML"
it "should wikify temperatures"
it "should wikify kids names"
it "should wikify recipe URIs"
end
wiki
makes this spec pass:def wiki(text)(commit)
text
end
Next up: making those other 4 examples pass.
No comments:
Post a Comment