Skip to content

Commit

Permalink
Prevent collisions on let :name and :method_name in rspec-rails examples
Browse files Browse the repository at this point in the history
Fix: #2451
  • Loading branch information
benoittgt authored and pirj committed Feb 19, 2021
1 parent 8edb660 commit 4aa5e0b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/rspec/rails/fixture_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module FixtureSupport
include RSpec::Rails::MinitestAssertionAdapter
include ActiveRecord::TestFixtures

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

included do
Expand Down

0 comments on commit 4aa5e0b

Please sign in to comment.