[rspec-users] Failing on rake but not on textmate (rails)

Dan Herrera dan at revelationglobal.com
Thu Jul 24 16:17:10 EDT 2008

On Thu, Jul 24, 2008 at 12:27 PM, Macario Ortega <lists at ruby-forum.com> wrote:
> Rick Denatale wrote:
>> On Mon, Jul 21, 2008 at 8:34 PM, Mark Wilden <mark.wilden at gmail.com>
>> wrote:
>>> don't know if that explains the behavior you're seeing.
>>>> I would like to use autotest but I can't trust the results.
>>> autotest also does not copy the database structure. I've been using it for
>>> six months and I've never noticed a problem with it. Why don't you trust it?
>>> I doubt that it's a problem with not copy the database structure from dev
>> to test. That sync's the db schema and would only be needed after a
>> schema
>> change (i.e. one or more migrations have been run), and it would be much
>> more likely to cause a failure in Textmate when the code under test
>> doesn't
>> see the expected db schema.
>> It's more likely that there are undeclared fixtures affecting the spec,
>> a
>> spec which needs particular state in the database might succeed or not
>> depending on whether or not previous specs either left data behind, or
>> deleted data needed by the spec in question.
>> When I've seen cases where test/specs behaved differently when run
>> separately vs. being run in batch (e.g. by Rake) it's almost always
>> because
>> I left out a fixture declaration.
>> --
>> Rick DeNatale
>> My blog on Ruby
>> http://talklikeaduck.denhaven2.com/
> Hi, thanks for the answer today I ran rake several times and all my test
> passed (and that made me very happy) but suddenly the tests for this
> model started failing again.

We get failures at times when running specs with rake spec that we
can't reproduce when running in Textmate.  We came to the conclusion
that it may have something to do with transactions not rolling back
before the start of the next test.  So even though the models we
create should be unique (we create them with some randomness built
in), we will get validation failures when saving a new record to the

You may want to try turning off transactions with:
  config.use_transactional_fixtures = false
and see if that makes a difference.

We are using Rspec 1.1.4 and PostgreSQL as our db.  Let me know if that helps.


> Prior to each test I delete all records for the model and I have no
> fixture for that particular model.
> I am just starting with sdd and I find fixtures to give me more trouble
> than they solve so when I need to populate the database I create and
> save the models I need thus I have all the dependencies.
> What do you mean by undeclared fixture? a fixture with no data?
> What is strange is that some validation specs ('it should require name')
> that don't depend on database also fail.

More information about the rspec-users mailing list