Skip to content

Commit

Permalink
Prevent collision on :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 committed Feb 17, 2021
1 parent ac17fd4 commit e841f0a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/rspec/rails/fixture_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ 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 patch to avoid colision on :name method in Rails 6.1 and
# :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 e841f0a

Please sign in to comment.