<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">I come from the same background as you, so I hear where you're coming
<br>from. We made a conscious decision, however, not to support custom
<br>messages almost two years ago and I'm not sure if its ever even come
<br>up before. If it has, it was a long time ago.
</blockquote><div><br>[nod] Perhaps as I get into the mindset, I'll find this desire slips away.<br></div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
If you follow the conventions of one expectation per example, and your
<br>example is well named, this is less of a problem. Here's a common
<br>idiom:
<br>
<br>describe Person do
<br> def valid_attributes
<br> {:name => 'joe smith'}
<br> end
<br> before(:each) do
<br> @person = Person.new(valid_attributes)
<br> end
<br> it "should be valid with valid attributes" do
<br> @person.should be_valid
<br> end
<br> it "should be invalid with no name" do
<br> @<a href="http://person.name">person.name</a> = nil
<br> @person.should_not be_valid
<br> end
<br>end
</blockquote><div><br>Using this as an example, if a new validation rule is added, this test will fail without indicating /why/. Sure, I can get that answer in other ways, but I'd hate to discover things like:<br><br>
it "should be valid with valid attributes" do<br> # puts @person.errors if !@person.valid<br> @person.should be_valid<br>end <br><br>(Which I've seen when people have to repeatedly diagnose issues in a test; I'd prefer a failure message to the above)
<br></div><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">Together, these different examples help to tell the whole story, and
<br>when one example fails you know why it's failing - its just that the
<br>message is in the example's name instead of a custom assertion
<br>message.
</blockquote><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">Make sense?
</blockquote><br>Yes and no; test isolation and good names is a decent practice even in XUnit, but clearly it's that much stronger in RSpec, and I'm in favour of that. However, I find that often test failures involve unexpected changes (
e.g. the REST service didn't return a status code of 201, as you expected, because a validation rule changed and the validation failed), which aren't as easy to message.<br><br>Still, i'm willing to give this approach a shot and see if this bothers me increasingly less.
<br><br> - Geoffrey<br>-- <br>Geoffrey Wiseman<br>