diff --git a/spec/migration_lock_timeout/migration_spec.rb b/spec/migration_lock_timeout/migration_spec.rb index c2b3909..9ac6aa4 100644 --- a/spec/migration_lock_timeout/migration_spec.rb +++ b/spec/migration_lock_timeout/migration_spec.rb @@ -5,23 +5,28 @@ require 'strong_migrations' if Gem.loaded_specs.has_key? 'strong_migrations' require_relative '../../lib/migration-lock-timeout' -ACTIVE_RECORD_MIGRATION_CLASS = if ActiveRecord.gem_version < '5.0' - ActiveRecord::Migration - else - ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f] - end +ACTIVE_RECORD_MIGRATION_CLASS = ActiveRecord::Migration[ActiveRecord::VERSION::STRING.to_f] def expect_create_table - expect(ActiveRecord::Base.connection).to receive(:execute). - with('BEGIN', 'TRANSACTION'). + if ActiveRecord.gem_version >= '7.1' + expect(ActiveRecord::Base.connection).to receive(:execute). + with(/ROLLBACK/). + and_call_original + expect(ActiveRecord::Base.connection).to receive(:execute). + with(/CREATE TABLE/). and_call_original - expect(ActiveRecord::Base.connection).to receive(:execute). - with(/CREATE TABLE/). - and_call_original + else + expect(ActiveRecord::Base.connection).to receive(:execute). + with('BEGIN', 'TRANSACTION'). + and_call_original + expect(ActiveRecord::Base.connection).to receive(:execute). + with(/CREATE TABLE/). + and_call_original + end end RSpec.describe ActiveRecord::Migration do - + before { ActiveRecord::Base.logger = Logger.new(STDOUT) } describe '#migrate' do before(:each) do