[rspec-users] Interdependency between RSpec files
glenn at aldenta.com
Wed Nov 14 11:37:14 EST 2007
I run my suite of tests, one test fails.
I run that one test file, no tests fail.
Something is carrying over between files and I can't figure out what.
I tracked down the problem to the very line it's occurring on, with
printouts before and after every call to make sure I know exactly what
is being reached.
In this spec I have 0 fixtures/mocks/stubs. The objects in this file
do not live anywhere outside of the file. This is a model spec and
I'm using all real objects to test it. In the "before" block I set up
some models, and in my spec itself I, in each test, make a couple
changes then call a model's save method. That model has an
"after_create" method which calls a method in a child model that it
has. It is THIS method which is not being called. I have printouts
before and after everything, like I said, and the lines before and
after the method call work, which leads me to believe that method IS
getting called. However I have a "puts 'foo'" at the top of that
method and it doesn't get printed.
The object is not nil, and it has even been successfully saved
previously in the code, and all of its necessary attributes have been
set. Why on earth is it not getting called? Keep in mind, it DOES
get called if I run "spec" on that specific file. If I run it among
my other spec files (I've got lots) it DOES NOT get called.
I need some ideas on how to chase this one down? I stuck printouts
everywhere to track the issue down as narrowly as I have but I'm down
to a single line and it's doing something I didn't even know was
physically possible in this language. It seems I must be overlooking
something but I just can't seem to see outside of the box on this
issue. Any ideas would be great, thanks!
More information about the rspec-users