[rspec-rails] spec vs. autospec

Hi All,

any reason why some tests might pass via spec … and fail from within
autospec?

I have a rails app using AuthLogic and Declarative Authorization. I
have tests that create user_sessions and assign roles against which
CRUD rules are tested.

This has bee working just fine.

But this morning I updated the Declarative Auth gem and suddenly
started seeing failing tests. I immediately blamed DA, or really my
usage of it. But then I started running the spec files individually
via “spec …” commands and everything started passing - which was
actually more disturbing for me.

so now I wonder what autospec might be doing that is different from
straight “spec …” commands?

when I run “rake spec” they fail just like in autospec - there’s some
comforting consistency, failing tests notwithstanding.

thanks for any insights

2009/12/4 Andy K. [email protected]

comforting consistency, failing tests notwithstanding.

thanks for any insights


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Generally this indicates a problem with one spec interfering with
another.
Run separately the specs run fine, because the state is completely reset
between each run. However run together (and this can be order dependent,
just to add to the confusion) and they break. Debugging this can be
quite
tricky, monitoring the test database, and the test.log should help.
However
generally I find that you just have to pay real close attention to any
specs
that create any sort of permanent artifact, and any specs that rely on
there
being a certain number of artifacts e.g. the first role.

All best

Andrew

Thanks Andrew,

That was the right hint.

I took the autospec command list of all specs and ran them in smaller
groups - which led to discovering a Declarative Auth config switch
that was heretofore isolated. Apparently in the new version of this
gem it does not get reset between tests.

Once I removed those WMD’s of auth control all my tests returned to
normal.

Another lesson learned, muchas gracias.

regards,
Andy