[rspec-users] Transactional fixtures for Gem (not Rails) development

214 views
Skip to first unread message

medihack

unread,
Dec 10, 2010, 7:14:57 AM12/10/10
to rspec...@rubyforge.org
Hello.

Is it possible to also use the transactional examples feature for gem
(not Rails) development. It seems that one has to require "rspec-
rails", but I still can't get it to work.

I added this to my spec_helper.rb:
RSpec.configure do |config|
config.use_transactional_fixtures = true
end

And also required:
require 'rubygems'
require 'bundler'
require 'logger'
require 'active_record'
require 'rails'
require 'rspec-rails'
require 'active_support'

But I get that error when running a test:
undefined method `use_transactional_fixtures=' for
#<RSpec::Core::Configuration:0xb706d0bc> (NoMethodError)
although I required rspec-rails and rails as mentioned above

Is it simply not possible to use transactional examples for gem
development?

Best regards,
Kai
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

David Chelimsky

unread,
Dec 10, 2010, 7:52:47 AM12/10/10
to rspec-users
On Dec 10, 2010, at 6:14 AM, medihack wrote:

> Hello.
>
> Is it possible to also use the transactional examples feature for gem
> (not Rails) development.

Nope. That feature is not implemented in RSpec, it is implemented in Rails. RSpec just provides access to it.

> It seems that one has to require "rspec-
> rails", but I still can't get it to work.
>
> I added this to my spec_helper.rb:
> RSpec.configure do |config|
> config.use_transactional_fixtures = true
> end
>
> And also required:
> require 'rubygems'
> require 'bundler'
> require 'logger'
> require 'active_record'
> require 'rails'
> require 'rspec-rails'
> require 'active_support'
>
> But I get that error when running a test:
> undefined method `use_transactional_fixtures=' for
> #<RSpec::Core::Configuration:0xb706d0bc> (NoMethodError)
> although I required rspec-rails and rails as mentioned above
>
> Is it simply not possible to use transactional examples for gem
> development?

You can (and probably should) use the database_cleaner gem. Directions for using it with RSpec are at the bottom of the README on https://github.com/bmabey/database_cleaner.

Cheers,
David

Reply all
Reply to author
Forward
0 new messages