GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
I'm not sure whether this is a bug or intended (but undocumented) behaviour, but blocks defined with config.before are executed outside of Active Record's transactions.
I created a sample Rails app that reproduces this problem: https://github.com/exviva/rspec_before_transactions.
Notice the spec_helper.rb:
RSpec.configure do |config|
config.use_transactional_fixtures = true
Then, there are two examples in post_spec.rb, which expose the fact that database state is not isolated between them:
describe Post do
it 'executes config.before within the transaction' do
it 'executes config.before within the transaction the second time' do
I managed to reproduce it using RSpec 2.8 and Rails 3.1.3 and 3.2.0. I haven't tried any other version.
Pretty sure this has the same root cause as #391.
#391 is resolved; going to resolve this one too. If that's not appropriate, let me know and we can reopen.