[rspec-users] rspec (steak) turning off transactional fixtures

David Chelimsky dchelimsky at gmail.com
Wed Jun 16 14:47:43 EDT 2010


On Jun 16, 2010, at 1:37 PM, Marcelo de Moraes Serpa wrote:

> Hi David,
> 
> Yeah, I'm using DatabaseCleaner, pretty much familiar with it.
> 
> The issue is that passing it to rspec's yielded config object didn't seem to disable transactional_fixtures:
> 
> Spec::Runner.configure do |config|
> 
>   config.before(:each) do
>     if options[:js] #using culerity
>       Capybara.current_driver = :culerity
>       config.use_transactional_
> fixtures = false
>     end
>   end
> 
>   config.after(:each) do
>     if  options[:js]
>       DatabaseCleaner.clean
>       Capybara.use_default_driver
>       config.use_transactional_fixtures = true
>     end
>   end
> 
> end
> 
> Check the lines "config.use_transactional_fixtures" on both callbacks. I doesn't seem to disable them. Any ideas?

Not sure why that doesn't work, but that's not what I was proposing. I'm saying use database cleaner _instead_ of config.use_transactional_fixtures:

Spec::Runner.configure do |c|
  c.use_transactional_fixtures = false
  c.before do
    if options[:js]
      DatabaseCleaner.strategy = :truncation
    else
      DatabaseCleaner.strategy = :transaction
    end
    DatabaseCleaner.start
  end
  c.after do
    DatabaseCleaner.clean
  end
end

Make sense?

> 
> Marcelo.
> 
> 
> On Tue, Jun 15, 2010 at 5:32 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Jun 15, 2010, at 5:15 PM, Marcelo de Moraes Serpa wrote:
> 
> > Hey all,
> >
> > I have replaced Cucumber with Steak and I like the experience so far. It is not as polished as Cucumber in what comes to configuration, but it is simpler and covers my needs perfectly. I've followed the trick to pass a hash to the example in order to setup Capybara to use a different driver, like so:
> >
> > spec/acceptance/support/javascript.rb
> >
> > Spec::Runner.configure do |config|
> >
> >   config.before(:each) do
> >     if options[:js] #using culerity
> >       Capybara.current_driver = :culerity
> >       config.use_transactional_fixtures = false
> >     end
> >   end
> >
> >   config.after(:each) do
> >     if  options[:js]
> >       DatabaseCleaner.clean
> >       Capybara.use_default_driver
> >       config.use_transactional_fixtures = true
> >     end
> >   end
> >
> > end
> >
> > As you can see, if an example has an option with :js => true, it will use culerity, and this works fine. What doesn't seem to work is the use_transactional_fixtures = false conf. I still can't access the data outside of the ruby instance (i.e: the app server celerity is accessing doesn't have access to the fixture data). With Cucumber it would be a matter of setting up Cucumber::Rails::World.use_transactional_fixtures to false.
> >
> > How could I disable transactional fixtures on a per example base when using rspec / steak?
> 
> As far as I know, this is not easy, or maybe even possible, with the Rails built-in framework. What I'd do is turn off the rails features (config.use_transactional_fixtures = false) and use database_cleaner. Are you familiar w/ database_cleaner?
> 
> David
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
> 
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100616/6a1baaf9/attachment-0001.html>


More information about the rspec-users mailing list