Unwanted fixture data messing up my other tests

I have a fixture for one of my tables that i use in some model tests.
The
data in it is messing up some other tests for a different model, that
doesn’t ask for the fixture - isn’t the fixture data supposed to be
cleared
out of the test db in between tests, and only be present if specifically
asked for? or am i using them wrong?

thanks
max

On Thu, Feb 21, 2008 at 6:17 AM, Max W.
[email protected] wrote:

I have a fixture for one of my tables that i use in some model tests. The
data in it is messing up some other tests for a different model, that
doesn’t ask for the fixture - isn’t the fixture data supposed to be cleared
out of the test db in between tests, and only be present if specifically
asked for? or am i using them wrong?

It depends on settings you have in spec_helper.rb. You should have this:

config.use_transactional_fixtures = true

You should also not be declaring any fixtures in spec_helper.rb, given
your situation.

HTH,
David

Hi David

I have that option set already, and i’m not using any fixtures in
spec_helper. My spec helper looks like this: is it the
use_instantiated_fixtures option perhaps? (i don’t know what that
does).

thanks, max

ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) +
“/…/config/environment”)
require ‘spec’
require ‘spec/rails’
require ‘spec/custom_matchers’

Spec::Runner.configure do |config|

If you’re not using ActiveRecord you should remove these

lines, delete config/database.yml and disable :active_record

in your config/boot.rb

config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + ‘/spec/fixtures/’

#custom stuff
config.include(CustomMatchers)

def mock_login_required(allow_user_to_pass=true)
controller.stub!(:login_required).and_return(allow_user_to_pass)
end

def mock_admin_user?(allow_user_to_pass=true)
controller.stub!(:admin_user?).and_return(allow_user_to_pass)
end

def mock_current_user(id = 1)
@user = mock_model(User, :to_param => id.to_s, :id => 1)
controller.stub!(:current_user).and_return(@user)
end
end
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<