data_migrate 8.5.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build.yml +34 -0
  3. data/.github/workflows/gempush.yml +6 -7
  4. data/.gitignore +3 -1
  5. data/Appraisals +0 -4
  6. data/Changelog.md +40 -0
  7. data/README.md +9 -7
  8. data/data_migrate.gemspec +1 -10
  9. data/lib/data_migrate/config.rb +1 -1
  10. data/lib/data_migrate/{data_migrator_five.rb → data_migrator.rb} +1 -12
  11. data/lib/data_migrate/data_schema.rb +1 -1
  12. data/lib/data_migrate/database_tasks.rb +32 -72
  13. data/lib/data_migrate/{schema_migration_six.rb → schema_migration.rb} +4 -2
  14. data/lib/data_migrate/{status_service_five.rb → status_service.rb} +12 -6
  15. data/lib/data_migrate/tasks/data_migrate_tasks.rb +15 -36
  16. data/lib/data_migrate/version.rb +1 -1
  17. data/lib/data_migrate.rb +3 -8
  18. data/spec/data_migrate/config_spec.rb +13 -10
  19. data/spec/data_migrate/data_migrator_spec.rb +13 -34
  20. data/spec/data_migrate/data_spec.rb +0 -11
  21. data/spec/data_migrate/database_tasks_spec.rb +10 -58
  22. data/spec/data_migrate/legacy_migrator_spec.rb +6 -18
  23. data/spec/data_migrate/migration.rb +11 -13
  24. data/spec/data_migrate/migration_context_spec.rb +11 -37
  25. data/spec/data_migrate/schema_dumper_spec.rb +10 -23
  26. data/spec/data_migrate/schema_migration_spec.rb +40 -42
  27. data/spec/data_migrate/status_service_spec.rb +26 -55
  28. data/spec/data_migrate/tasks/data_migrate_tasks_spec.rb +31 -66
  29. data/spec/db/data/20091231235959_some_name.rb +1 -1
  30. data/spec/db/data/20171231235959_super_update.rb +1 -1
  31. data/spec/spec_helper.rb +2 -8
  32. data/tasks/databases.rake +15 -13
  33. metadata +14 -31
  34. data/.ruby-version +0 -1
  35. data/.travis.yml +0 -14
  36. data/Gemfile.rails5.2 +0 -10
  37. data/gemfiles/rails_5.2.gemfile +0 -8
  38. data/lib/data_migrate/schema_migration_five.rb +0 -31
  39. data/spec/db/6.0/20091231235959_some_name.rb +0 -9
  40. data/spec/db/6.0/20171231235959_super_update.rb +0 -9
  41. data/spec/db/data-6.0/20091231235959_some_name.rb +0 -9
  42. data/spec/db/data-6.0/20171231235959_super_update.rb +0 -9
  43. data/spec/db/data-6.0/20181128000207_excluded_file.rb.other_ext +0 -1
  44. data/spec/db/migrate/5.2/20131111111111_late_migration.rb +0 -9
  45. data/spec/db/migrate/5.2/20202020202011_db_migration.rb +0 -9
  46. /data/spec/db/migrate/{6.0/20131111111111_late_migration.rb → 20131111111111_late_migration.rb} +0 -0
  47. /data/spec/db/migrate/{6.0/20202020202011_db_migration.rb → 20202020202011_db_migration.rb} +0 -0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DataMigrate::Config do
@@ -11,41 +13,42 @@ describe DataMigrate::Config do
11
13
 
12
14
  describe "data migration path configured" do
13
15
  subject { DataMigrate.config.data_migrations_path }
16
+ let(:data_migrations_path) { "db/awesome/" }
17
+
14
18
  before do
15
- @before = DataMigrate.config.data_migrations_path
19
+ @original_data_migrations_path = DataMigrate.config.data_migrations_path
20
+
16
21
  DataMigrate.configure do |config|
17
- config.data_migrations_path = "db/awesome/"
22
+ config.data_migrations_path = data_migrations_path
18
23
  end
19
24
  end
20
25
 
21
26
  after do
22
27
  DataMigrate.configure do |config|
23
- config.data_migrations_path = @before
28
+ config.data_migrations_path = @original_data_migrations_path
24
29
  end
25
30
  end
26
31
 
27
32
  it "equals the custom data migration path" do
28
- is_expected.to eq "db/awesome/"
33
+ is_expected.to eq(data_migrations_path)
29
34
  end
30
35
  end
31
36
 
32
37
  describe "data template path configured" do
33
38
  subject { DataMigrate.config.data_template_path }
39
+ let(:data_template_path) { File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb") }
34
40
 
35
41
  before do
36
- @before = DataMigrate.config.data_template_path
42
+ @original_data_migrations_path = DataMigrate.config.data_template_path
43
+
37
44
  DataMigrate.configure do |config|
38
45
  config.data_template_path = data_template_path
39
46
  end
40
47
  end
41
48
 
42
- let(:data_template_path) do
43
- File.join(DataMigrate.root, "generators", "data_migration", "templates", "data_migration.rb")
44
- end
45
-
46
49
  after do
47
50
  DataMigrate.configure do |config|
48
- config.data_template_path = @before
51
+ config.data_template_path = @original_data_migrations_path
49
52
  end
50
53
  end
51
54
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DataMigrate::DataMigrator do
@@ -10,25 +12,18 @@ describe DataMigrate::DataMigrator do
10
12
  end
11
13
 
12
14
  before do
13
- allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }
14
15
  ActiveRecord::Base.establish_connection(db_config)
16
+ ::ActiveRecord::SchemaMigration.create_table
17
+ DataMigrate::DataSchemaMigration.create_table
15
18
  end
16
19
 
17
- describe :load_migrated do
18
- before do
19
- allow(subject).to receive(:db_config) { db_config }.at_least(:once)
20
- ActiveRecord::Base.establish_connection(db_config)
21
- ::ActiveRecord::SchemaMigration.create_table
22
- DataMigrate::DataSchemaMigration.create_table
23
- end
24
-
25
- after do
26
- ActiveRecord::Migration.drop_table("data_migrations")
27
- ActiveRecord::Migration.drop_table("schema_migrations")
28
- end
20
+ after do
21
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
22
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
23
+ end
29
24
 
30
- it do
31
- subject.assure_data_schema_table
25
+ describe ".load_migrated" do
26
+ it "loads migrated versions" do
32
27
  DataMigrate::DataSchemaMigration.create(version: 20090000000000)
33
28
  ::ActiveRecord::SchemaMigration.create(version: 20100000000000)
34
29
  DataMigrate::DataSchemaMigration.create(version: 20110000000000)
@@ -40,19 +35,10 @@ describe DataMigrate::DataMigrator do
40
35
  end
41
36
  end
42
37
 
43
- describe :assure_data_schema_table do
44
- before do
45
- allow(subject).to receive(:db_config) { db_config }.at_least(:once)
46
- ActiveRecord::Base.establish_connection(db_config)
47
- end
48
-
49
- after do
50
- ActiveRecord::Migration.drop_table("data_migrations")
51
- end
52
-
53
- it do
38
+ describe :create_data_schema_table do
39
+ it "creates the data_migrations table" do
54
40
  ActiveRecord::Migration.drop_table("data_migrations") rescue nil
55
- subject.assure_data_schema_table
41
+ subject.create_data_schema_table
56
42
  expect(
57
43
  ActiveRecord::Base.connection.table_exists?("data_migrations")
58
44
  ).to eq true
@@ -60,13 +46,6 @@ describe DataMigrate::DataMigrator do
60
46
  end
61
47
 
62
48
  describe "#migrations_status" do
63
- before do
64
- allow(subject).to receive(:db_config) { db_config }.at_least(:once)
65
- ActiveRecord::Base.establish_connection(db_config)
66
- ::ActiveRecord::SchemaMigration.create_table
67
- DataMigrate::DataSchemaMigration.create_table
68
- end
69
-
70
49
  it "returns all migrations statuses" do
71
50
  status = subject.migrations_status
72
51
  expect(status.length).to eq 2
@@ -4,12 +4,6 @@ require "spec_helper"
4
4
 
5
5
  describe DataMigrate::Data do
6
6
  let(:subject) { DataMigrate::Data }
7
- let(:db_config) do
8
- {
9
- adapter: "sqlite3",
10
- database: "spec/db/test.db"
11
- }
12
- end
13
7
  let(:fixture_file_timestamps) do
14
8
  %w[20091231235959 20101231235959 20111231235959]
15
9
  end
@@ -28,11 +22,6 @@ describe DataMigrate::Data do
28
22
  end
29
23
 
30
24
  describe :define do
31
- before do
32
- allow(DataMigrate::DataMigrator).
33
- to receive(:db_config) { db_config }
34
- end
35
-
36
25
  after do
37
26
  ActiveRecord::Migration.drop_table("data_migrations")
38
27
  end
@@ -4,13 +4,7 @@ require "spec_helper"
4
4
 
5
5
  describe DataMigrate::DatabaseTasks do
6
6
  let(:subject) { DataMigrate::DatabaseTasks }
7
- let(:migration_path) {
8
- if Rails::VERSION::MAJOR == 5
9
- "spec/db/migrate/5.2"
10
- else
11
- "spec/db/migrate/6.0"
12
- end
13
- }
7
+ let(:migration_path) { "spec/db/migrate" }
14
8
  let(:data_migrations_path) {
15
9
  DataMigrate.config.data_migrations_path
16
10
  }
@@ -33,9 +27,8 @@ describe DataMigrate::DatabaseTasks do
33
27
  allow(DataMigrate::Tasks::DataMigrateTasks).to receive(:migrations_paths) {
34
28
  data_migrations_path
35
29
  }
36
- allow(DataMigrate::DataMigrator).to receive(:db_config) { db_config }
37
30
  ActiveRecord::Base.establish_connection(db_config)
38
- if Rails.version >= '6.1'
31
+ if Gem::Dependency.new("railties", ">= 6.1").match?("railties", Gem.loaded_specs["railties"].version)
39
32
  hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new('test', 'test', db_config)
40
33
  config_obj = ActiveRecord::DatabaseConfigurations.new([hash_config])
41
34
  allow(ActiveRecord::Base).to receive(:configurations).and_return(config_obj)
@@ -44,19 +37,10 @@ describe DataMigrate::DatabaseTasks do
44
37
  end
45
38
  end
46
39
 
47
- describe :schema_file do
48
- it "returns the correct data schema file path" do
49
- expect(subject.schema_file(nil)).to eq "db/data_schema.rb"
50
- end
51
- end
52
-
53
40
  context "migrations" do
54
41
  after do
55
- begin
56
- ActiveRecord::Migration.drop_table("data_migrations")
57
- rescue ActiveRecord::StatementInvalid
58
- end
59
- ActiveRecord::Migration.drop_table("schema_migrations")
42
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
43
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
60
44
  end
61
45
 
62
46
  before do
@@ -68,51 +52,19 @@ describe DataMigrate::DatabaseTasks do
68
52
  allow(DataMigrate::DatabaseTasks).to receive(:data_migrations_path) {
69
53
  data_migrations_path
70
54
  }.at_least(:once)
71
- allow(DataMigrate::DatabaseTasks).to receive(:schema_migrations_path) {
72
- migration_path
73
- }.at_least(:once)
74
55
  end
75
56
 
76
57
  describe :past_migrations do
77
- it do
58
+ it "returns past migration records" do
78
59
  subject.forward
79
- m = subject.past_migrations
80
- expect(m.count).to eq 1
81
- expect(m.first[:version]).to eq 20091231235959
60
+ migrations = subject.past_migrations
61
+ expect(migrations.count).to eq 1
62
+ expect(migrations.first[:version]).to eq 20091231235959
82
63
  end
83
64
 
84
65
  it "shows nothing without any migrations" do
85
- m = subject.past_migrations
86
- expect(m.count).to eq 0
87
- end
88
- end
89
-
90
- describe :load_schema_current do
91
- before do
92
- allow(DataMigrate::DataMigrator).to receive(:full_migrations_path).and_return(migration_path)
93
- end
94
-
95
- it "loads the current schema file" do
96
- if Rails::VERSION::MAJOR < 6
97
- skip("Not implemented for Rails lower than 6")
98
- end
99
- allow(subject).to receive(:schema_location).and_return("spec/db/data/schema/")
100
-
101
- subject.load_schema_current
102
- versions = DataMigrate::DataSchemaMigration.normalized_versions
103
- expect(versions.count).to eq(2)
104
- end
105
-
106
- it "loads schema file that has not been update with latest data migrations" do
107
- if Rails::VERSION::MAJOR < 6
108
- skip("Not implemented for Rails lower than 6")
109
- end
110
-
111
- allow(subject).to receive(:schema_location).and_return("spec/db/data/partial_schema/")
112
-
113
- subject.load_schema_current
114
- versions = DataMigrate::DataSchemaMigration.normalized_versions
115
- expect(versions.count).to eq(1)
66
+ migrations = subject.past_migrations
67
+ expect(migrations.count).to eq 0
116
68
  end
117
69
  end
118
70
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DataMigrate::LegacyMigrator do
@@ -5,30 +7,17 @@ describe DataMigrate::LegacyMigrator do
5
7
  DataMigrate::MigrationContext.new("spec/db/data")
6
8
  }
7
9
 
8
- after do
9
- begin
10
- ActiveRecord::Migration.drop_table("data_migrations")
11
- ActiveRecord::Migration.drop_table("schema_migrations")
12
- rescue StandardError
13
- nil
14
- end
15
- end
16
-
17
10
  before do
18
- ActiveRecord::Base.establish_connection(db_config)
19
11
  ActiveRecord::SchemaMigration.create_table
20
12
  DataMigrate::DataSchemaMigration.create_table
21
13
  end
22
14
 
23
- let(:db_config) do
24
- {
25
- adapter: "sqlite3",
26
- database: "spec/db/test.db"
27
- }
15
+ after do
16
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
17
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
28
18
  end
29
19
 
30
20
  it "migrate legacy migrations to be in correct table" do
31
- DataMigrate::DataSchemaMigration.create_table
32
21
  # simulate creation of legacy data migration when
33
22
  # it was recorded in schema table
34
23
  ActiveRecord::SchemaMigration.create(version: "20091231235959")
@@ -36,7 +25,7 @@ describe DataMigrate::LegacyMigrator do
36
25
  # create one migration in correct place
37
26
  DataMigrate::DataSchemaMigration.create(version: "20171231235959")
38
27
 
39
- migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
28
+ migrated = DataMigrate::DataMigrator.new(:up, []).load_migrated
40
29
  expect(migrated.count).to eq 1
41
30
 
42
31
  DataMigrate::LegacyMigrator.new("spec/db/data").migrate
@@ -46,5 +35,4 @@ describe DataMigrate::LegacyMigrator do
46
35
  migrated = DataMigrate::DataMigrator .new(:up, []).load_migrated
47
36
  expect(migrated.count).to eq 2
48
37
  end
49
-
50
38
  end
@@ -1,19 +1,17 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- if Rails::VERSION::MAJOR >= 5
4
- subject = DataMigrate::MigrationFive
5
- else
6
- subject = DataMigrate::Migration
7
- end
3
+ require 'spec_helper'
8
4
 
9
- describe subject do
10
- it "uses correct table name" do
11
- expect(subject.table_name).to eq("data_migrations")
5
+ describe DataMigrate::Migration do
6
+ describe ".table_name" do
7
+ it "returns correct table name" do
8
+ expect(subject.table_name).to eq("data_migrations")
9
+ end
12
10
  end
13
11
 
14
- it "uses correct index name" do
15
- expect(subject).to receive(:table_name_prefix) { "" }
16
- expect(subject).to receive(:table_name_suffix) { "" }
17
- expect(subject.primary_key).to eq("version")
12
+ describe ".index_name" do
13
+ it "returns correct primary key name" do
14
+ expect(subject.primary_key).to eq("version")
15
+ end
18
16
  end
19
17
  end
@@ -1,48 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe DataMigrate::DataMigrator do
4
- let(:context) {
5
- if (Rails::VERSION::MAJOR == 5)
6
- DataMigrate::MigrationContext.new("spec/db/data")
7
- else
8
- DataMigrate::MigrationContext.new("spec/db/data-6.0")
9
- end
10
- }
11
- let(:schema_context) {
12
- if (Rails::VERSION::MAJOR == 5)
13
- ActiveRecord::MigrationContext.new("spec/db/migrate/5.2")
14
- else
15
- ActiveRecord::MigrationContext.new("spec/db/migrate/6.0", ActiveRecord::Base.connection.schema_migration)
16
- end
17
- }
6
+ let(:context) { DataMigrate::MigrationContext.new("spec/db/data") }
7
+ let(:schema_context) { ActiveRecord::MigrationContext.new("spec/db/migrate", ActiveRecord::Base.connection.schema_migration) }
18
8
 
19
- after do
20
- begin
21
- ActiveRecord::Migration.drop_table("data_migrations")
22
- ActiveRecord::Migration.drop_table("schema_migrations")
23
- rescue StandardError
24
- nil
25
- end
9
+ before do
10
+ ActiveRecord::SchemaMigration.create_table
11
+ DataMigrate::DataSchemaMigration.create_table
26
12
  end
27
13
 
28
- let(:db_config) do
29
- {
30
- adapter: "sqlite3",
31
- database: "spec/db/test.db"
32
- }
14
+ after do
15
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
16
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
33
17
  end
34
18
 
35
- describe :migrate do
36
- before do
37
- ActiveRecord::Base.establish_connection(db_config)
38
- ActiveRecord::SchemaMigration.create_table
39
- end
40
-
41
- after do
42
- ActiveRecord::Migration.drop_table("data_migrations")
43
- ActiveRecord::Migration.drop_table("schema_migrations")
44
- end
45
-
19
+ describe "migrate" do
46
20
  it "migrates existing file" do
47
21
  context.migrate(nil)
48
22
  context.migrations_status
@@ -4,35 +4,22 @@ require "spec_helper"
4
4
 
5
5
  describe DataMigrate::SchemaDumper do
6
6
  let(:subject) { DataMigrate::SchemaDumper }
7
- let(:db_config) do
8
- {
9
- adapter: "sqlite3",
10
- database: "spec/db/test.db"
11
- }
12
- end
13
7
  let(:fixture_file_timestamps) do
14
8
  %w[20091231235959 20101231235959 20111231235959]
15
9
  end
16
10
 
17
- describe :dump do
18
- before do
19
- allow(DataMigrate::DataMigrator).
20
- to receive(:db_config) { db_config }.at_least(:once)
21
- ActiveRecord::Base.establish_connection(db_config)
22
-
23
- ActiveRecord::SchemaMigration.create_table
24
- DataMigrate::DataMigrator.assure_data_schema_table
25
-
26
- ActiveRecord::Base.connection.execute <<-SQL
27
- INSERT INTO #{DataMigrate::DataSchemaMigration.table_name}
28
- VALUES #{fixture_file_timestamps.map { |t| "(#{t})" }.join(', ')}
29
- SQL
30
- end
11
+ before do
12
+ ActiveRecord::SchemaMigration.create_table
13
+ DataMigrate::DataSchemaMigration.create_table
14
+ DataMigrate::DataSchemaMigration.create(fixture_file_timestamps.map { |t| { version: t } })
15
+ end
31
16
 
32
- after do
33
- ActiveRecord::Migration.drop_table("data_migrations")
34
- end
17
+ after do
18
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
19
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
20
+ end
35
21
 
22
+ describe ".dump" do
36
23
  it "writes the define method with the version key to the stream" do
37
24
  stream = StringIO.new
38
25
  DataMigrate::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
@@ -3,32 +3,20 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe DataMigrate::SchemaMigration do
6
- let(:migration_path) {
7
- if Rails::VERSION::MAJOR == 5
8
- "spec/db/migrate/5.2"
9
- else
10
- "spec/db/migrate/6.0"
11
- end
12
- }
13
-
14
6
  let(:subject) { DataMigrate::SchemaMigration }
15
- let(:db_config) do
16
- {
17
- adapter: "sqlite3",
18
- database: "spec/db/test.db"
19
- }
20
- end
7
+ let(:migration_path) { "spec/db/migrate" }
21
8
  let(:fixture_file_timestamps) do
22
9
  %w[20091231235959 20101231235959 20111231235959]
23
10
  end
24
11
 
25
12
  before do
26
- ActiveRecord::Base.establish_connection(db_config)
27
13
  ActiveRecord::SchemaMigration.create_table
14
+ DataMigrate::DataSchemaMigration.create_table
28
15
  end
29
16
 
30
17
  after do
31
- ActiveRecord::Migration.drop_table("schema_migrations")
18
+ ActiveRecord::Migration.drop_table("data_migrations") rescue nil
19
+ ActiveRecord::Migration.drop_table("schema_migrations") rescue nil
32
20
  end
33
21
 
34
22
  describe :pending_schema_migrations do
@@ -36,6 +24,7 @@ describe DataMigrate::SchemaMigration do
36
24
  expect(subject).to receive(:migrations_paths) {
37
25
  migration_path
38
26
  }
27
+
39
28
  migrations = subject.pending_schema_migrations
40
29
 
41
30
  expect(migrations.count).to eq 2
@@ -45,7 +34,7 @@ describe DataMigrate::SchemaMigration do
45
34
  end
46
35
 
47
36
  describe :run do
48
- it do
37
+ it "can run up task" do
49
38
  expect {
50
39
  subject.run(:up, migration_path, 20202020202011)
51
40
  }.to output(/20202020202011 DbMigration: migrating/).to_stdout
@@ -53,47 +42,56 @@ describe DataMigrate::SchemaMigration do
53
42
  expect(versions.first).to eq("20202020202011")
54
43
  end
55
44
 
56
- it "undo migration" do
45
+ it "can run down task" do
57
46
  subject.run(:up, migration_path, 20202020202011)
47
+
58
48
  expect {
59
49
  subject.run(:down, migration_path, 20202020202011)
60
50
  }.to output(/Undoing DbMigration/).to_stdout
51
+
61
52
  versions = ActiveRecord::SchemaMigration.normalized_versions
53
+
62
54
  expect(versions.count).to eq(0)
63
55
  end
64
56
  end
65
57
 
66
- if Rails.version > '6'
67
- describe :migrations_paths do
68
- context 'when a db_name is configured' do
69
- let(:config) { double(:config) }
70
- let(:paths) { ['spec/db/migrate/6.0', 'spec/db/components/migrate/6.0'] }
71
- let(:config_options) do
72
- if Rails.version > '6.1'
73
- { env_name: 'test', name: 'primary' }
74
- else
75
- { env_name: 'test', spec_name: 'primary' }
76
- end
58
+ describe :migrations_paths do
59
+ context 'when a db_name is configured' do
60
+ let(:config) { double(:config) }
61
+ let(:paths) { ['spec/db/migrate', 'spec/db/migrate/other'] }
62
+ let(:specification_name) { "primary" }
63
+ let(:config_options) do
64
+ if Gem::Dependency.new("railties", "~> 6.0").match?("railties", Gem.loaded_specs["railties"].version)
65
+ { env_name: Rails.env, spec_name: specification_name }
66
+ elsif Gem::Dependency.new("railties", "~> 7.0").match?("railties", Gem.loaded_specs["railties"].version)
67
+ { env_name: Rails.env, name: specification_name }
77
68
  end
69
+ end
78
70
 
79
- before do
80
- DataMigrate.configure do |config|
81
- config.spec_name = 'primary'
82
- end
83
-
84
- allow(ActiveRecord::Base.configurations)
85
- .to receive(:configs_for)
86
- .with(config_options)
87
- .and_return(config)
71
+ before do
72
+ @original_config_spec_name = DataMigrate.config.spec_name
88
73
 
89
- allow(config).to receive(:migrations_paths).and_return(paths)
74
+ DataMigrate.configure do |config|
75
+ config.spec_name = specification_name
90
76
  end
91
77
 
92
- it 'lists schema migration paths' do
93
- expect(subject.migrations_paths.size).to eq(2)
94
- expect(subject.migrations_paths).to eq(paths)
78
+ allow(ActiveRecord::Base.configurations)
79
+ .to receive(:configs_for)
80
+ .with(config_options)
81
+ .and_return(config)
82
+ allow(config).to receive(:migrations_paths).and_return(paths)
83
+ end
84
+
85
+ after do
86
+ DataMigrate.configure do |config|
87
+ config.spec_name = @original_config_spec_name
95
88
  end
96
89
  end
90
+
91
+ it 'lists schema migration paths' do
92
+ expect(subject.migrations_paths.size).to eq(paths.count)
93
+ expect(subject.migrations_paths).to eq(paths)
94
+ end
97
95
  end
98
96
  end
99
97
  end