Skip to content

Commit

Permalink
Remove specs for old rails versions
Browse files Browse the repository at this point in the history
  • Loading branch information
codez committed Dec 3, 2024
1 parent d3b8c6b commit 8302bd4
Showing 1 changed file with 21 additions and 50 deletions.
71 changes: 21 additions & 50 deletions spec/integration/apartment_rake_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,60 +47,31 @@
Company.delete_all
end

context 'with ActiveRecord below 5.2.0' do
before do
allow(ActiveRecord::Migrator).to receive(:migrations_paths) { %w[spec/dummy/db/migrate] }
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { true }
end

describe '#migrate' do
it 'should migrate all databases' do
expect(ActiveRecord::Migrator).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end

describe '#rollback' do
it 'should rollback all dbs' do
expect(ActiveRecord::Migrator).to receive(:rollback).exactly(company_count).times

@rake['apartment:rollback'].invoke
end
let(:migration_context_double) { double(:migration_context) }

Check failure on line 50 in spec/integration/apartment_rake_integration_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] spec/integration/apartment_rake_integration_spec.rb#L50

[Correctable] RSpec/ScatteredLet: Group all let/let! blocks in the example group together.
Raw output
spec/integration/apartment_rake_integration_spec.rb:50:5: C: [Correctable] RSpec/ScatteredLet: Group all let/let! blocks in the example group together.
    let(:migration_context_double) { double(:migration_context) }
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

describe '#migrate' do
it 'should migrate all databases' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end

context 'with ActiveRecord above or equal to 5.2.0' do
let(:migration_context_double) { double(:migration_context) }

before do
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { false }
end

describe '#migrate' do
it 'should migrate all databases' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:migrate).exactly(company_count).times

@rake['apartment:migrate'].invoke
end
end
describe '#rollback' do
it 'should rollback all dbs' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:rollback).exactly(company_count).times

describe '#rollback' do
it 'should rollback all dbs' do
if ActiveRecord.version >= Gem::Version.new('7.2.0')
allow(ActiveRecord::Base.connection_pool)
else
allow(ActiveRecord::Base.connection)
end.to receive(:migration_context) { migration_context_double }
expect(migration_context_double).to receive(:rollback).exactly(company_count).times

@rake['apartment:rollback'].invoke
end
@rake['apartment:rollback'].invoke
end
end

Expand Down

0 comments on commit 8302bd4

Please sign in to comment.