[rspec-users] How to run example group in transaction

Jim Morris wolfmanjm at gmail.com
Fri Mar 4 15:03:39 EST 2011

In your spec_helper...

RSpec.configure do |config|

  # setup transactional factory for sequel, when running transactional
  config.around(:each, :transactional => true) do |example|
    Sequel::DATABASES.first.transaction do
      raise Sequel::Error::Rollback


On Mar 4, 5:56 am, Zhi-Qiang Lei <zhiqiang.... at gmail.com> wrote:
> Dear All,
> I want to wrap my example group in transaction to avoid record being created. How should I do? My rspec is 2.5.1, and ORM is Sequal. This way does not work for me. Thanks.
> class RSpec::Core::ExampleGroup
>   def self.run(reporter)
>     DB.transaction { super(reporter); raise(Sequel::Error::Rollback) }
>   end
> end
> core_application_spec.rb:9:in `block in run': super: no superclass method `run' for RSpec::Core::ExampleGroup::Nested_1:Class (NoMethodError)
> Best regards,
> Zhi-Qiang Lei
> zhiqiang.... at gmail.com
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list