diff --git a/lib/rspec/rails/fixture_support.rb b/lib/rspec/rails/fixture_support.rb index 12acfdfbd..017993dad 100644 --- a/lib/rspec/rails/fixture_support.rb +++ b/lib/rspec/rails/fixture_support.rb @@ -12,8 +12,14 @@ module FixtureSupport # @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?(self) + if ::Rails::VERSION::STRING > '5' + def run_in_transaction? + use_transactional_tests && !self.class.uses_transaction?(self) + end + else + def run_in_transaction? + use_transactional_fixtures && !self.class.uses_transaction?(self) + end end included do