Rails 2.0 change breaks shoulda
Reported by Noel Rappin | January 10th, 2008 @ 04:54 PM
Rails changeset 8570 appears to allow setup chains to be declared in tests using the syntax
setup do
end
In any test which uses shoulda contexts with a setup block, this causes the setup block to be run before any tests, not just the tests in that context. It also seems to run the setup block before fixtures are loaded and such, causing pretty much any shoulda test using contexts to break.
Comments and changes to this ticket
-
Tammer Saleh February 5th, 2008 @ 10:14 AM
- → State changed from new to open
I'm still not sure of what to do about this. I don't think it's possible to code around it (or would be too complex of an implementation if it were).
The best idea I've got right now is to rename shouda's setup and teardown macros to before and after.
context "a thing" do before do @thing = Thing.new end .... endThe bad side of this, of course, is that it would break compatibility with older versions of shoulda. Any thoughts?
-
-

Earle Clubb February 5th, 2008 @ 10:50 AM
I think that's an acceptable solution. I don't know about other folks, but it would be trivial for me to refactor my tests.
-

Noel Rappin February 5th, 2008 @ 10:50 AM
I'd be totally fine with that change -- that's what I was considering doing locally as a workaround.
Noel
-

Shane Vitarana February 28th, 2008 @ 03:17 AM
Although I prefer setup and teardown, I'm okay with before and after in this case. Otherwise, I'm sure you'll run into some nasty issues with the new setup blocks.
-
Tammer Saleh February 28th, 2008 @ 02:56 PM
OK, I think I've finished a refactoring that fixes this (along with a few other pieces of ugly). The latest version of shoulda
https://svn.thoughtbot.com/plugi...
no longer defines setup or teardown on Test::Unit, and only honors those methods inside a context block.
Could someone do me a favor and verify that this solves this issue for rails edge?
Thanks,
Tammer
-

Shane Vitarana February 29th, 2008 @ 08:44 PM
Revision 375 with Rails trunk works for me. Thanks for the prompt fix!
-
Tammer Saleh March 3rd, 2008 @ 04:30 PM
- → State changed from open to resolved
Sweet. Thanks for the help.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
