Update documentation on testing with RSpec2 #522

Closed
markiz opened this Issue Jul 19, 2012 · 1 comment

Projects

None yet

2 participants

@markiz
markiz commented Jul 19, 2012

https://github.com/jeremyevans/sequel/blob/master/doc/testing.rdoc#rspec-2

Currently, it states:

class RSpec::Core::ExampleGroup
  # Setting an around filter globally doesn't appear to work in 2.7 (and maybe other versions),
  # so set one up for each subclass.
  def self.inherited(subclass)
    super
    subclass.around do |example|
      Sequel::Model.db.transaction(:rollback=>:always){example.call}
    end
  end
end

I am using sequel and rspec 2.8.0 and global filters do work.

Here's what I am using (:always_rollback option might be preferred to raise Sequel::Error::Rollback):

RSpec.configure do |c|
  c.around(:each) do |example|
    DB.transaction do
      example.run
      raise Sequel::Error::Rollback
    end
  end
end
@jeremyevans
Owner

OK. I'll split the example for Rspec < 2.8 and Rspec >= 2.8. Thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment