ridgepole 0.9.2 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/lib/ridgepole/delta.rb +1 -1
  4. data/lib/ridgepole/diff.rb +7 -3
  5. data/lib/ridgepole/execute_expander.rb +1 -1
  6. data/lib/ridgepole/ext/abstract_adapter/disable_table_options.rb +1 -0
  7. data/lib/ridgepole/version.rb +1 -1
  8. data/ridgepole.gemspec +7 -4
  9. metadata +6 -282
  10. data/.github/workflows/test.yml +0 -70
  11. data/.gitignore +0 -25
  12. data/spec/cli_helper.rb +0 -65
  13. data/spec/dsl_parser/context_spec.rb +0 -16
  14. data/spec/erb_helper.rb +0 -26
  15. data/spec/fixtures/for_require_relative_spec.rb +0 -3
  16. data/spec/hide_pending_formatter.rb +0 -9
  17. data/spec/mysql/_migrate/migrate_change_table_option_spec.rb +0 -40
  18. data/spec/mysql/bigint_pk/int_pk_spec.rb +0 -47
  19. data/spec/mysql/cli/config_spec.rb +0 -210
  20. data/spec/mysql/cli/ridgepole_spec.rb +0 -447
  21. data/spec/mysql/collation/collation_spec.rb +0 -153
  22. data/spec/mysql/comment/comment_spec.rb +0 -179
  23. data/spec/mysql/default_lambda/default_lambda_spec.rb +0 -164
  24. data/spec/mysql/diff/diff2_spec.rb +0 -189
  25. data/spec/mysql/diff/diff_spec.rb +0 -168
  26. data/spec/mysql/dump/dump_class_method_spec.rb +0 -74
  27. data/spec/mysql/dump/dump_some_tables_spec.rb +0 -70
  28. data/spec/mysql/dump/dump_spec.rb +0 -74
  29. data/spec/mysql/dump/dump_unknown_column_type_spec.rb +0 -28
  30. data/spec/mysql/dump/dump_without_table_options_spec.rb +0 -34
  31. data/spec/mysql/fk/migrate_change_fk2_spec.rb +0 -47
  32. data/spec/mysql/fk/migrate_change_fk_spec.rb +0 -265
  33. data/spec/mysql/fk/migrate_create_fk_spec.rb +0 -349
  34. data/spec/mysql/fk/migrate_drop_fk_spec.rb +0 -331
  35. data/spec/mysql/fk/migrate_fk_with_column_spec.rb +0 -163
  36. data/spec/mysql/fk/migrate_ignore_fk_spec.rb +0 -70
  37. data/spec/mysql/migrate/check_orphan_index_spec.rb +0 -83
  38. data/spec/mysql/migrate/migrate_add_column2_spec.rb +0 -159
  39. data/spec/mysql/migrate/migrate_add_column_order_spec.rb +0 -242
  40. data/spec/mysql/migrate/migrate_add_column_spec.rb +0 -161
  41. data/spec/mysql/migrate/migrate_add_column_with_alter_extra_spec.rb +0 -231
  42. data/spec/mysql/migrate/migrate_add_column_with_script_spec.rb +0 -152
  43. data/spec/mysql/migrate/migrate_change_column2_spec.rb +0 -91
  44. data/spec/mysql/migrate/migrate_change_column3_spec.rb +0 -404
  45. data/spec/mysql/migrate/migrate_change_column4_spec.rb +0 -83
  46. data/spec/mysql/migrate/migrate_change_column5_spec.rb +0 -129
  47. data/spec/mysql/migrate/migrate_change_column6_spec.rb +0 -241
  48. data/spec/mysql/migrate/migrate_change_column7_spec.rb +0 -25
  49. data/spec/mysql/migrate/migrate_change_column8_spec.rb +0 -87
  50. data/spec/mysql/migrate/migrate_change_column_default_spec.rb +0 -199
  51. data/spec/mysql/migrate/migrate_change_column_float_spec.rb +0 -75
  52. data/spec/mysql/migrate/migrate_change_column_spec.rb +0 -158
  53. data/spec/mysql/migrate/migrate_change_index2_spec.rb +0 -86
  54. data/spec/mysql/migrate/migrate_change_index3_spec.rb +0 -179
  55. data/spec/mysql/migrate/migrate_change_index4_spec.rb +0 -112
  56. data/spec/mysql/migrate/migrate_change_index5_spec.rb +0 -74
  57. data/spec/mysql/migrate/migrate_change_index6_spec.rb +0 -202
  58. data/spec/mysql/migrate/migrate_change_index7_spec.rb +0 -85
  59. data/spec/mysql/migrate/migrate_change_index8_spec.rb +0 -85
  60. data/spec/mysql/migrate/migrate_change_index_spec.rb +0 -235
  61. data/spec/mysql/migrate/migrate_change_table_comment_spec.rb +0 -72
  62. data/spec/mysql/migrate/migrate_change_table_option_spec.rb +0 -83
  63. data/spec/mysql/migrate/migrate_check_relation_column_type_spec.rb +0 -225
  64. data/spec/mysql/migrate/migrate_create_index2_spec.rb +0 -203
  65. data/spec/mysql/migrate/migrate_create_index_spec.rb +0 -220
  66. data/spec/mysql/migrate/migrate_create_table_spec.rb +0 -123
  67. data/spec/mysql/migrate/migrate_create_table_with_ignore_spec.rb +0 -45
  68. data/spec/mysql/migrate/migrate_create_table_with_index_spec.rb +0 -43
  69. data/spec/mysql/migrate/migrate_create_table_with_options_spec.rb +0 -59
  70. data/spec/mysql/migrate/migrate_create_table_with_script_spec.rb +0 -132
  71. data/spec/mysql/migrate/migrate_drop_column_and_index2_spec.rb +0 -140
  72. data/spec/mysql/migrate/migrate_drop_column_and_index_spec.rb +0 -167
  73. data/spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb +0 -52
  74. data/spec/mysql/migrate/migrate_drop_column_spec.rb +0 -158
  75. data/spec/mysql/migrate/migrate_drop_index_spec.rb +0 -160
  76. data/spec/mysql/migrate/migrate_drop_table_spec.rb +0 -123
  77. data/spec/mysql/migrate/migrate_duplicate_index_spec.rb +0 -27
  78. data/spec/mysql/migrate/migrate_duplicate_table_spec.rb +0 -37
  79. data/spec/mysql/migrate/migrate_empty_spec.rb +0 -78
  80. data/spec/mysql/migrate/migrate_execute_spec.rb +0 -288
  81. data/spec/mysql/migrate/migrate_ignore_column_spec.rb +0 -98
  82. data/spec/mysql/migrate/migrate_ignore_index_spec.rb +0 -92
  83. data/spec/mysql/migrate/migrate_log_file_spec.rb +0 -125
  84. data/spec/mysql/migrate/migrate_merge_mode_spec.rb +0 -145
  85. data/spec/mysql/migrate/migrate_noop_spec.rb +0 -234
  86. data/spec/mysql/migrate/migrate_primary_key_spec.rb +0 -104
  87. data/spec/mysql/migrate/migrate_rename_column_spec.rb +0 -184
  88. data/spec/mysql/migrate/migrate_rename_table_spec.rb +0 -241
  89. data/spec/mysql/migrate/migrate_same_default_null_spec.rb +0 -77
  90. data/spec/mysql/migrate/migrate_same_spec.rb +0 -82
  91. data/spec/mysql/migrate/migrate_script_error_spec.rb +0 -91
  92. data/spec/mysql/migrate/migrate_skip_column_comment_change_spec.rb +0 -39
  93. data/spec/mysql/migrate/migrate_skip_drop_table_spec.rb +0 -145
  94. data/spec/mysql/migrate/migrate_skip_rename_column_spec.rb +0 -140
  95. data/spec/mysql/migrate/migrate_skip_rename_table_spec.rb +0 -141
  96. data/spec/mysql/migrate/migrate_with_ignore_tables_spec.rb +0 -307
  97. data/spec/mysql/migrate/migrate_with_pre_post_query_spec.rb +0 -153
  98. data/spec/mysql/migrate/migrate_with_tables_spec.rb +0 -149
  99. data/spec/mysql/migrate/migrate_with_verbose_log_spec.rb +0 -60
  100. data/spec/mysql/ridgepole_test_database.sql +0 -2
  101. data/spec/mysql/ridgepole_test_tables.sql +0 -79
  102. data/spec/mysql/ridgepole_test_tables_unknown_column_type.sql +0 -17
  103. data/spec/mysql/text_blob_types/text_blob_types_spec.rb +0 -131
  104. data/spec/mysql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  105. data/spec/mysql/~default_name_fk/migrate_create_fk_spec.rb +0 -133
  106. data/spec/mysql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  107. data/spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb +0 -43
  108. data/spec/mysql57/json/add_json_column_spec.rb +0 -35
  109. data/spec/mysql57/json/change_json_column_spec.rb +0 -102
  110. data/spec/mysql57/json/drop_json_column_spec.rb +0 -35
  111. data/spec/mysql57/virtual/add_virtual_column_spec.rb +0 -37
  112. data/spec/mysql57/virtual/change_virtual_column_spec.rb +0 -40
  113. data/spec/mysql57/virtual/drop_virtual_column_spec.rb +0 -37
  114. data/spec/postgresql/diff/diff_spec.rb +0 -216
  115. data/spec/postgresql/dump/dump_spec.rb +0 -69
  116. data/spec/postgresql/fk/migrate_change_fk_spec.rb +0 -115
  117. data/spec/postgresql/fk/migrate_create_fk_spec.rb +0 -176
  118. data/spec/postgresql/fk/migrate_drop_fk_spec.rb +0 -197
  119. data/spec/postgresql/migrate/migrate_add_column_spec.rb +0 -203
  120. data/spec/postgresql/migrate/migrate_add_expression_index_spec.rb +0 -25
  121. data/spec/postgresql/migrate/migrate_bigint_spec.rb +0 -53
  122. data/spec/postgresql/migrate/migrate_change_column_default_spec.rb +0 -38
  123. data/spec/postgresql/migrate/migrate_change_column_spec.rb +0 -185
  124. data/spec/postgresql/migrate/migrate_change_index_spec.rb +0 -164
  125. data/spec/postgresql/migrate/migrate_check_relation_column_type_spec.rb +0 -114
  126. data/spec/postgresql/migrate/migrate_create_table_spec.rb +0 -120
  127. data/spec/postgresql/migrate/migrate_create_table_with_default_proc_spec.rb +0 -112
  128. data/spec/postgresql/migrate/migrate_drop_column_spec.rb +0 -163
  129. data/spec/postgresql/migrate/migrate_drop_column_with_index_spec.rb +0 -166
  130. data/spec/postgresql/migrate/migrate_drop_expression_index_spec.rb +0 -59
  131. data/spec/postgresql/migrate/migrate_drop_index_spec.rb +0 -158
  132. data/spec/postgresql/migrate/migrate_drop_table_spec.rb +0 -122
  133. data/spec/postgresql/migrate/migrate_ext_cols_spec.rb +0 -64
  134. data/spec/postgresql/migrate/migrate_primary_key2_spec.rb +0 -73
  135. data/spec/postgresql/migrate/migrate_primary_key_spec.rb +0 -99
  136. data/spec/postgresql/migrate/migrate_references_spec.rb +0 -90
  137. data/spec/postgresql/migrate/migrate_rename_column_spec.rb +0 -155
  138. data/spec/postgresql/migrate/migrate_rename_table_spec.rb +0 -175
  139. data/spec/postgresql/migrate/migrate_same_spec.rb +0 -77
  140. data/spec/postgresql/ridgepole_test_database.sql +0 -16
  141. data/spec/postgresql/ridgepole_test_tables.sql +0 -75
  142. data/spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb +0 -59
  143. data/spec/postgresql/~default_name_fk/migrate_create_fk_spec.rb +0 -134
  144. data/spec/postgresql/~default_name_fk/migrate_drop_fk_spec.rb +0 -100
  145. data/spec/processing_for_ci.rb +0 -13
  146. data/spec/spec_condition.rb +0 -58
  147. data/spec/spec_const.rb +0 -20
  148. data/spec/spec_helper.rb +0 -173
data/.gitignore DELETED
@@ -1,25 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- .DS_Store
19
- test.rb
20
- Schemafile
21
- *.schema
22
- _site/
23
- config.yml
24
- /gemfiles/*.lock
25
- *.swp
data/spec/cli_helper.rb DELETED
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CLIHelper
4
- def default_cli_hook
5
- <<-RUBY.strip_heredoc
6
- require 'ridgepole'
7
-
8
- class Ridgepole::Delta
9
- def initialize(*args);
10
- end
11
- def migrate(*args)
12
- puts "Ridgepole::Delta#migrate"
13
- [#{differ}, "create_table :table do\\nend"]
14
- end
15
- def script
16
- puts "Ridgepole::Delta#script"
17
-
18
- "create_table :table do\\nend"
19
- end
20
- def differ?
21
- puts "Ridgepole::Delta#differ?"
22
- #{differ}
23
- end
24
- end
25
-
26
- class Ridgepole::Client
27
- def initialize(*args)
28
- puts "Ridgepole::Client#initialize([\#{args.map {|i| i.kind_of?(File) ? i.path : i.inspect}.join(', ')}])"
29
- end
30
- def dump
31
- puts "Ridgepole::Client#dump"
32
- end
33
- def diff(*args)
34
- puts "Ridgepole::Client#diff"
35
- Ridgepole::Delta.new
36
- end
37
- class << self
38
- def diff(*args)
39
- puts "Ridgepole::Client.diff([\#{args.map {|i| i.kind_of?(File) ? i.path : i.inspect}.join(', ')}])"
40
- Ridgepole::Delta.new
41
- end
42
- def dump(args)
43
- puts "Ridgepole::Client.dump"
44
- end
45
- end
46
- end
47
- RUBY
48
- end
49
-
50
- def run_cli(options = {})
51
- args = options[:args] || []
52
- hook = options[:hook] || default_cli_hook
53
- path = File.expand_path('../bin/ridgepole', __dir__)
54
-
55
- Tempfile.open(["#{File.basename __FILE__}.#{$PROCESS_ID}", '.rb']) do |f|
56
- f.puts(hook)
57
- f.puts(File.read(path))
58
- f.flush
59
-
60
- cmd = ([:ruby, f.path] + args).join(' ')
61
- Open3.capture2e(cmd)
62
- end
63
- end
64
- end
65
- include CLIHelper
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe Ridgepole::DSLParser::Context do
4
- describe '#require_relative' do
5
- subject { context.require_relative(relative_path) }
6
-
7
- let!(:context) do
8
- Ridgepole::DSLParser::Context.new
9
- end
10
- let!(:relative_path) do
11
- '../fixtures/for_require_relative_spec.rb'
12
- end
13
-
14
- it { is_expected.to be_truthy }
15
- end
16
- end
data/spec/erb_helper.rb DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- include ERBh
4
-
5
- ERBh.define_method(:i) do |obj|
6
- if obj.nil? || (obj.respond_to?(:empty?) && obj.empty?)
7
- @_erbout.sub!(/,\s*\z/, '')
8
- ''
9
- elsif obj.is_a?(Hash)
10
- obj.modern_inspect_without_brace
11
- else
12
- obj
13
- end
14
- end
15
-
16
- ERBh.define_method(:cond) do |conds, m, e = nil|
17
- if condition(conds)
18
- m
19
- else
20
- e || (begin
21
- m.class.new
22
- rescue StandardError
23
- nil
24
- end)
25
- end
26
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- 'This file is used by dsl_parser/context_spec.'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class HidePendingFormatter < RSpec::Core::Formatters::ProgressFormatter
4
- RSpec::Core::Formatters.register self, :example_pending
5
- RSpec::Core::Formatters.register self, :dump_pending
6
- def example_pending(notification); end
7
-
8
- def dump_pending(notification); end
9
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client#diff -> migrate' do
4
- context 'when change mysql table options' do
5
- let(:actual_dsl) do
6
- erbh(<<-ERB)
7
- create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond(">= 6.1", { charset: "utf8", options: "ENGINE=MyISAM" }, { options: "ENGINE=MyISAM DEFAULT CHARSET=utf8" }) %> do |t|
8
- t.date "birth_date", null: false
9
- t.string "first_name", limit: 14, null: false
10
- t.string "last_name", limit: 16, null: false
11
- t.string "gender", limit: 1, null: false
12
- t.date "hire_date", null: false
13
- end
14
- ERB
15
- end
16
-
17
- let(:expected_dsl) do
18
- erbh(<<-ERB)
19
- create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond(">= 6.1", { charset: "ascii" }, { options: "ENGINE=InnoDB DEFAULT CHARSET=ascii" }) %> do |t|
20
- t.date "birth_date", null: false
21
- t.string "first_name", limit: 14, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
22
- t.string "last_name", limit: 16, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
23
- t.string "gender", limit: 1, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
24
- t.date "hire_date", null: false
25
- end
26
- ERB
27
- end
28
-
29
- before { subject.diff(actual_dsl).migrate }
30
- subject { client(dump_without_table_options: false, mysql_change_table_options: true) }
31
-
32
- it {
33
- delta = subject.diff(expected_dsl)
34
- expect(delta.differ?).to be_truthy
35
- expect(subject.dump).to match_ruby actual_dsl
36
- delta.migrate
37
- expect(subject.dump).to match_ruby expected_dsl
38
- }
39
- end
40
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe 'Ridgepole::Client (with integer pk)' do
4
- context 'when with id:integer' do
5
- let(:dsl) do
6
- <<-RUBY
7
- create_table "books", id: :integer, force: :cascade do |t|
8
- t.string "title", null: false
9
- t.integer "author_id", null: false
10
- t.datetime "created_at"
11
- t.datetime "updated_at"
12
- end
13
- RUBY
14
- end
15
-
16
- subject { client }
17
-
18
- before { subject.diff(dsl).migrate }
19
-
20
- specify do
21
- expect(show_create_table(:books)).to include '`id` int(11) NOT NULL AUTO_INCREMENT'
22
- expect(subject.dump).to match_ruby dsl
23
- end
24
- end
25
-
26
- context 'when without id:integer' do
27
- let(:dsl) do
28
- <<-RUBY
29
- create_table "books", force: :cascade do |t|
30
- t.string "title", null: false
31
- t.integer "author_id", null: false
32
- t.datetime "created_at"
33
- t.datetime "updated_at"
34
- end
35
- RUBY
36
- end
37
-
38
- subject { client }
39
-
40
- before { subject.diff(dsl).migrate }
41
-
42
- specify do
43
- expect(show_create_table(:books)).to include '`id` bigint(20) NOT NULL AUTO_INCREMENT'
44
- expect(subject.dump).to match_ruby dsl
45
- end
46
- end
47
- end
@@ -1,210 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe Ridgepole::Config do
4
- subject { Ridgepole::Config.load(config, env, spec_name) }
5
-
6
- let(:spec_name) { '' }
7
-
8
- context 'when passed toplevel yaml' do
9
- let(:config) do
10
- <<-YAML.strip_heredoc
11
- adapter: mysql2
12
- encoding: utf8
13
- database: blog
14
- username: root
15
- YAML
16
- end
17
- let(:env) { 'development' }
18
- specify do
19
- expect(subject['adapter']).to eq 'mysql2'
20
- expect(subject['encoding']).to eq 'utf8'
21
- expect(subject['database']).to eq 'blog'
22
- expect(subject['username']).to eq 'root'
23
- end
24
- end
25
-
26
- context 'when passed dynamic yaml' do
27
- let(:config) do
28
- <<-YAML.strip_heredoc
29
- adapter: mysql2
30
- encoding: utf8
31
- database: blog_<%= 1 + 2 %>
32
- username: user_<%= 3 * 4 %>
33
- YAML
34
- end
35
- let(:env) { 'development' }
36
- specify do
37
- expect(subject['adapter']).to eq 'mysql2'
38
- expect(subject['encoding']).to eq 'utf8'
39
- expect(subject['database']).to eq 'blog_3'
40
- expect(subject['username']).to eq 'user_12'
41
- end
42
- end
43
-
44
- context 'when passed rails database.yml style yaml' do
45
- let(:config) do
46
- <<-YAML.strip_heredoc
47
- development:
48
- adapter: sqlspecifye
49
- database: db/sample.db
50
- production:
51
- adapter: mysql2
52
- encoding: utf8
53
- database: blog
54
- username: root
55
- YAML
56
- end
57
-
58
- context 'in development env' do
59
- let(:env) { 'development' }
60
- specify do
61
- expect(subject['adapter']).to eq 'sqlspecifye'
62
- expect(subject['database']).to eq 'db/sample.db'
63
- expect(subject['username']).to be_nil
64
- end
65
- end
66
-
67
- context 'in production env' do
68
- let(:env) { 'production' }
69
- specify do
70
- expect(subject['adapter']).to eq 'mysql2'
71
- expect(subject['encoding']).to eq 'utf8'
72
- expect(subject['database']).to eq 'blog'
73
- expect(subject['username']).to eq 'root'
74
- end
75
- end
76
- end
77
-
78
- context 'when passed yaml file' do
79
- let(:config) do
80
- <<-YAML.strip_heredoc
81
- adapter: mysql2
82
- encoding: utf8
83
- database: blog
84
- username: root
85
- YAML
86
- end
87
- let(:env) { 'development' }
88
- it {
89
- Tempfile.create('database.yml') do |f|
90
- f.puts config
91
- f.flush
92
-
93
- expect(subject['adapter']).to eq 'mysql2'
94
- expect(subject['encoding']).to eq 'utf8'
95
- expect(subject['database']).to eq 'blog'
96
- expect(subject['username']).to eq 'root'
97
- end
98
- }
99
- end
100
-
101
- context 'when passed unexisting yaml' do
102
- let(:config) do
103
- 'database.yml'
104
- end
105
-
106
- let(:env) { 'development' }
107
-
108
- specify do
109
- expect do
110
- subject
111
- end.to raise_error %(Invalid config: 'scheme' is empty: "database.yml")
112
- end
113
- end
114
-
115
- context 'when passed DATABASE_URL' do
116
- let(:config) { 'mysql2://root:pass@127.0.0.1:3307/blog?pool=5&reaping_frequency=2' }
117
- let(:env) { 'development' }
118
-
119
- it {
120
- expect(subject['adapter']).to eq 'mysql2'
121
- expect(subject['database']).to eq 'blog'
122
- expect(subject['username']).to eq 'root'
123
- expect(subject['password']).to eq 'pass'
124
- expect(subject['port']).to eq 3307
125
- expect(subject['pool']).to eq '5'
126
- expect(subject['reaping_frequency']).to eq '2'
127
- }
128
- end
129
-
130
- context 'when passed Heroku style DATABASE_URL' do
131
- let(:config) { 'postgres://root:pass@127.0.0.1:5432/blog' }
132
- let(:env) { 'development' }
133
-
134
- it {
135
- expect(subject['adapter']).to eq 'postgresql'
136
- expect(subject['database']).to eq 'blog'
137
- expect(subject['username']).to eq 'root'
138
- expect(subject['password']).to eq 'pass'
139
- expect(subject['port']).to eq 5432
140
- }
141
- end
142
-
143
- context 'when passed DATABASE_URL from ENV' do
144
- let(:config) { 'env:DATABASE_URL' }
145
- let(:env) { 'development' }
146
-
147
- before do
148
- allow(ENV).to receive(:fetch).with('DATABASE_URL').and_return('mysql2://root:pass@127.0.0.1:3307/blog')
149
- end
150
-
151
- it {
152
- expect(subject['adapter']).to eq 'mysql2'
153
- expect(subject['database']).to eq 'blog'
154
- expect(subject['username']).to eq 'root'
155
- expect(subject['password']).to eq 'pass'
156
- expect(subject['port']).to eq 3307
157
- }
158
- end
159
-
160
- context 'when passed rails database.yml multiple databases style yaml' do
161
- let(:config) do
162
- <<-YAML.strip_heredoc
163
- development:
164
- primary:
165
- adapter: sqlspecifye
166
- database: db/sample.db
167
- production:
168
- primary:
169
- adapter: mysql2
170
- encoding: utf8
171
- database: blog
172
- username: root
173
- primary_replica:
174
- adapter: mysql2
175
- encoding: utf8
176
- database: blog
177
- username: readonly
178
- YAML
179
- end
180
-
181
- context 'in development env with primary spec name' do
182
- let(:env) { 'development' }
183
- let(:spec_name) { 'primary' }
184
- specify do
185
- expect(subject['adapter']).to eq 'sqlspecifye'
186
- expect(subject['database']).to eq 'db/sample.db'
187
- expect(subject['username']).to be_nil
188
- end
189
- end
190
-
191
- context 'in production env with primary spec name' do
192
- let(:env) { 'production' }
193
- let(:spec_name) { 'primary' }
194
- specify do
195
- expect(subject['adapter']).to eq 'mysql2'
196
- expect(subject['encoding']).to eq 'utf8'
197
- expect(subject['database']).to eq 'blog'
198
- expect(subject['username']).to eq 'root'
199
- end
200
- end
201
-
202
- context 'in production env with primary_replica spec name' do
203
- let(:env) { 'production' }
204
- let(:spec_name) { 'primary_replica' }
205
- specify do
206
- expect(subject['username']).to eq 'readonly'
207
- end
208
- end
209
- end
210
- end