How to run example group in transaction

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 methodrun’ for RSpec::Core::ExampleGroup::Nested_1:Class
(NoMethodError)

Best regards,
Zhi-Qiang L.
[email protected]

In your spec_helper…

RSpec.configure do |config|

setup transactional factory for sequel, when running transactional

tests
config.around(:each, :transactional => true) do |example|
Sequel::DATABASES.first.transaction do
example.run
raise Sequel::Error::Rollback
end
end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs