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.
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.
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.
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).
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.
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?
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?
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.