in a controller in Rails 3, keep in mind that the body of the action will still happen before it doesn’t find a
it is interested in and bails, possibly causing side effects of the action to still happen (like creating a record) but returning a 406 or other error to the client.
“Time.stub(:now) combined with waits”
Careful when stubbing
when using, for example, steps in Cucumber that are “waiting” for things, as the clock will not move, and your tests will run until the end of time…
A quick gotcha we ran into when using polymorphic path and rspec2 today.
In a controller test we had an assertion:
Which resulted in the following error
Failure/Error: Unable to find matching line from backtrace stack level too deep
It turns out polymorphic path is not available in the controller test (but the usual object_path method is). As to why this throws a stack level too deep and not a method undefined looks like potentially another bug in rspec but the solution seemed to be to do the following in our spec_helper.b for Rails 3:
For Rails 2.x you’ll want to use:
I’ve opened an issue for this on github as well https://github.com/rspec/rspec-expectations/issues/issue/46