[rspec]. Inexplicable error in simple specs

Hello.

I am having strange errors running some specs.

I have just installed the nifty_scaffolds gem from Ryan B., and ran
“script/generate nifty_authentication --rspec --haml”, I have prepared
the databases, and run the specs, and I have almost all the specs
failing.
The odd thing is that it only fails when I run all the spec together,
but not
when I ran models and controllers independently.

“rake spec:models” pass for all the specs
“rake spec:controllers” pass for all the specs.

But “rake spec” fails in a dozen of model tests. Also “autospec” fails.

The code seems clear and ok, and I can’t understand why even simple
specs for require presence of a field fails.

I have only notice as unusual the use of view integration in the
controllers specs. Does anyone know about something I can be missing?

Thanks
Juanma

Well
It seems that the problem is not with the view integration but with the
fixtures.
I didn’t know if the fixtures loaded in the spec of a controller may
affect the specs of the model, but they indeed do.
I thought each spec runs in its own database transaction and the data
does not affect other spec. Is it true?
Thanks

On Sun, May 3, 2009 at 3:36 AM, Juanma C. [email protected]
wrote:

Well
It seems that the problem is not with the view integration but with the
fixtures.
I didn’t know if the fixtures loaded in the spec of a controller may
affect the specs of the model, but they indeed do.
I thought each spec runs in its own database transaction and the data
does not affect other spec. Is it true?

Assuming everything is set up correctly, yes. But there are several
things that could break that, including:

  • the wrong configuration in spec/spec_helper.rb
  • the wrong type of database tables in mysql (gotta use innodb)
  • setting up fixtures in before(:all) instead of before(:each)

Also, this sort of thing is often a sign that the either the examples
are leaking state by setting up globals, or the app itself might be
doing so.

HTH,
David