On 9/7/07, <b class="gmail_sendername">Pat Maddox</b> <<a href="mailto:pergesu@gmail.com">pergesu@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
describe MyModel, " when saved twice" do<br></blockquote></div><br>This is the key point I hadn't considered; makes sense, as long as you make sure that there's a context wherein the specification that it should have a certain number of revisions. Thanks!
<br><br>Realized this afternoon that I need to use finer-grained 'test methods' than I'm used to. In some ways the it blocks are closer to assertions than to test methods in Test::Unit, in some ways. So I went from my first crack, closer to:
<br><br>describe Customer, "xml" do<br> before do<br> # set up customer<br> end<br><br> it "should generate valid summary xml" do<br> # generate summary xml<br> # a bunch of shoulds about the xml
<br> end<br><br> it "should generate valid full xml" do<br> # generate full xml<br> # a bunch of shoulds<br> end<br>end<br><br>To something like this:<br>describe Customer, "full xml" do<br>
before do<br>
# set up customer full xml<br>
end<br>
<br>
it "should have a root node of customer" do<br> @doc.root.name.should == 'customer'<br>
end<br>
<br>
it "should contain a customer id" <br> it "should have a name and address"<br><br> #etc<br>
end<br><br>describe Customer, "summary xml" do<br> # etc.<br>end<br>
<br>So I guess I'm still learning the mindset in places. Although you could ahve test methods like that in Test::Unit, most of the time you wouldn't bother simply because of the shared setup. But when the blocks affect how the spec is described, it's far more important to have fine-grained elements, I think.
<br><br>Actually, on that note -- what's the normal way to share a setup across multiple behaviors, a helper method in an includeable module?<br><br>So, thanks for the guidance.<br>