Rspec fixtures stay in the test db - is this right?

I have some fixtures set up to put a few records in some of my tables.
In some of my rspec describe blocks, i’m not calling the fixtures, and
expecting the tables to be empty. But they’re not - the fixture data is
in there.

Am i using fixtures wrongly? I thought that the db was wiped at the
start of every test and the fixtures were only added if asked for. Is
that not the case? I’m new to rspec and can’t find much about fixtures
in the documentation.

thanks
max

Are you by any chance running this with a Sqlite db? I am running into
the same problem and I vaguely remember that Sqlite does not support
transactions. Which is set in my spec_helper.rb. Perhaps that throws
Rspec off.

With kind regards,
Harm

On Feb 7, 10:51 am, Max W. [email protected]

On Thu, Feb 7, 2008 at 5:51 AM, Max W.
[email protected] wrote:

I have some fixtures set up to put a few records in some of my tables.
In some of my rspec describe blocks, i’m not calling the fixtures, and
expecting the tables to be empty. But they’re not - the fixture data is
in there.

Am i using fixtures wrongly? I thought that the db was wiped at the
start of every test and the fixtures were only added if asked for. Is
that not the case? I’m new to rspec and can’t find much about fixtures
in the documentation.

RSpec just wraps Rails testing infrastructure, so you should see the
same behaviour in rspec or test/unit.

David C. wrote:

On Thu, Feb 7, 2008 at 5:51 AM, Max W.
[email protected] wrote:

I have some fixtures set up to put a few records in some of my tables.
In some of my rspec describe blocks, i’m not calling the fixtures, and
expecting the tables to be empty. But they’re not - the fixture data is
in there.

Am i using fixtures wrongly? I thought that the db was wiped at the
start of every test and the fixtures were only added if asked for. Is
that not the case? I’m new to rspec and can’t find much about fixtures
in the documentation.

RSpec just wraps Rails testing infrastructure, so you should see the
same behaviour in rspec or test/unit.

Hi David

You actually answered this question in another mailing list a while ago

  • it was because my fixture data was being loaded in a before :all
    rather than before :each - and so couldn’t be rolled back out of
    existence when the describe block finished. So, every time i ran the
    test the data was stacking up. Just in case anyone else was wondering
    (sorry, i should have replied to this post myself once i found the
    answer).

thanks
max

On Fri, Mar 28, 2008 at 11:46 AM, Max W.
[email protected] wrote:

Am i using fixtures wrongly? I thought that the db was wiped at the
start of every test and the fixtures were only added if asked for. Is
that not the case? I’m new to rspec and can’t find much about fixtures
in the documentation.

RSpec just wraps Rails testing infrastructure, so you should see the
same behaviour in rspec or test/unit.

Hi David

You actually answered this question in another mailing list a while ago

Ah - difficult to keep track of who is who sometimes! Glad you got it
resolved.

Cheers,
David

Max:

How are you loading your fixture data from within a before(:each)
block? The “fixtures” method isn’t available within that block. Are
you doing it manually somehow?

Ian

On Mar 28, 8:46 am, Max W. [email protected]

Ian Lesperance wrote:

Max:

How are you loading your fixture data from within a before(:each)
block? The “fixtures” method isn’t available within that block. Are
you doing it manually somehow?

Ian

On Mar 28, 8:46�am, Max W. [email protected]

What i’m doing now is having the fixtures call as the first line in a
describe block. I can’t remember what i was doing all that time ago
(only march? seems like years), probably something dumb :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs