Skip to content

Commit 4aa5e0b

Browse files
benoittgtpirj
authored andcommitted
Prevent collisions on let :name and :method_name in rspec-rails examples
Fix: #2451
1 parent 8edb660 commit 4aa5e0b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/rspec/rails/fixture_support.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ module FixtureSupport
99
include RSpec::Rails::MinitestAssertionAdapter
1010
include ActiveRecord::TestFixtures
1111

12-
if ::Rails.version.to_f >= 6.1
13-
# @private return the example name for TestFixtures
14-
def name
15-
@example
16-
end
12+
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
13+
# Monkey patched to avoid collisions with 'let(:name)' in Rails 6.1 and after
14+
# and let(:method_name) before Rails 6.1.
15+
def run_in_transaction?
16+
use_transactional_tests && !self.class.uses_transaction?(@example)
1717
end
1818

1919
included do

0 commit comments

Comments
 (0)