steven_noble
2011-Aug-10 21:53 UTC
[rspec-users] How to stop Rspec loading my Cucumber fixtures
I have a bunch of fixtures designed to populate the database for my Cucumber
integration tests.
But at this stage I want my database to be empty when using Rspec.
So, I moved the fixtures from `/spec/fixtures` to
`features/support/fixtures`, and updated `features/support/env.rb` to read:
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, ''features'',
''support'',
''fixtures'')
fixtures = Dir[File.join(fixtures_folder, ''*.yml'')].map
{|f|
File.basename(f, ''.yml'') }
Fixtures.create_fixtures(fixtures_folder, fixtures)
So far so good. Cucumber still loads the fixtures I moved as planned.
But Rspec is still loading them too! This is despite `spec/spec_helper.rb`
saying:
config.fixture_path = "#{::Rails.root}/spec/fixtures"
I have tried setting the following in `spec/spec_helper.rb`:
config.use_transactional_fixtures = false
However, it doesn''t work. And it wouldn''t be a long-term
solution anyway, as
I may need fixtures in Rspec in the future.
How can I fix this?
(Cross-posted from StackOverflow where there was no response.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20110810/8682749e/attachment.html>
David Chelimsky
2011-Aug-16 11:49 UTC
[rspec-users] How to stop Rspec loading my Cucumber fixtures
On Aug 10, 2011, at 4:53 PM, steven_noble wrote:> I have a bunch of fixtures designed to populate the database for my Cucumber integration tests. > > But at this stage I want my database to be empty when using Rspec. > > So, I moved the fixtures from `/spec/fixtures` to `features/support/fixtures`, and updated `features/support/env.rb` to read: > > Fixtures.reset_cache > fixtures_folder = File.join(RAILS_ROOT, ''features'', ''support'', ''fixtures'') > fixtures = Dir[File.join(fixtures_folder, ''*.yml'')].map {|f| File.basename(f, ''.yml'') } > Fixtures.create_fixtures(fixtures_folder, fixtures) > > So far so good. Cucumber still loads the fixtures I moved as planned. > > But Rspec is still loading them too! This is despite `spec/spec_helper.rb` saying: > > config.fixture_path = "#{::Rails.root}/spec/fixtures" > > I have tried setting the following in `spec/spec_helper.rb`: > > config.use_transactional_fixtures = falseuse_transactional_fixtures is a bit misleading: it''s a hook from Rails that really means "run each example in a transaction." There is no way to globally turn fixtures on or off - you either declare fixtures (in which case the underlying framework will go look for them) or not (in which case it won''t).> However, it doesn''t work. And it wouldn''t be a long-term solution anyway, as I may need fixtures in Rspec in the future. > > How can I fix this?How are you running rspec and cucumber?