Skip to content

Commit 8d0c698

Browse files
authored
Fix Zeus (#211)
The Zeus config has been broken since integration tests for Rails engines were added. It appears that the Zeus boot step responsible for loading Combustion was passing an empty array for the modules to initialize. Outside of Zeus, the integration test customizes this array, but inside Zeus, that never happens, and there isn't a way to do that. So, considering that we only have one engine-specific integration test, I removed the customization option and hardcoded the list of modules, renaming the boot step and corresponding command to match. I then corrected the test accordingly.
1 parent 32673c0 commit 8d0c698

File tree

9 files changed

+56
-52
lines changed

9 files changed

+56
-52
lines changed

config/zeus_plan.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@ class CustomZeusPlan < Zeus::Plan
1414
:boot_active_support,
1515
:boot_active_record,
1616
:boot_rails,
17+
:boot_rails_engine_with_action_controller,
1718
:run_plain_test,
1819
:run_rspec_active_support_test,
1920
:run_rspec_active_record_test,
20-
:run_rspec_rails_test
21+
:run_rspec_rails_test,
22+
:run_rspec_rails_engine_with_action_controller_test
2123
)
2224

2325
def initialize(
2426
using_outside_of_zeus: false,
2527
color_enabled: false,
26-
configuration: {}
28+
super_diff_configuration: {}
2729
)
2830
@test_plan =
2931
TestPlan.new(
3032
using_outside_of_zeus: using_outside_of_zeus,
3133
color_enabled: color_enabled,
32-
configuration: configuration
34+
super_diff_configuration: super_diff_configuration
3335
)
3436
end
3537
end

spec/integration/rails/engines_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
require "spec_helper"
22

3-
RSpec.describe "Integration with Rails engines", type: :integration do
3+
RSpec.describe "Integration with Rails engines",
4+
type: :integration,
5+
active_support: true do
46
context "when ActiveRecord is not loaded via Combustion" do
57
it "does not fail to load" do
68
as_both_colored_and_uncolored do |color_enabled|
79
program =
8-
make_rspec_rails_engine_program(
10+
make_rspec_rails_engine_with_action_controller_program(
911
"expect(true).to be(true)",
10-
combustion_initialize: [:action_controller],
1112
color_enabled: color_enabled
1213
)
1314

15+
expect(program).to produce_output_when_run(
16+
"1 example, 0 failures"
17+
).in_color(color_enabled)
18+
1419
expect(program).not_to produce_output_when_run(
1520
"uninitialized constant ActiveRecord"
1621
).in_color(color_enabled)

spec/support/integration/helpers.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def as_both_colored_and_uncolored
99
def make_plain_test_program(
1010
test,
1111
color_enabled:,
12-
configuration: {},
12+
super_diff_configuration: {},
1313
preserve_as_whole_file: false
1414
)
1515
TestPrograms::Plain.new(
1616
test,
1717
color_enabled: color_enabled,
18-
configuration: configuration,
18+
super_diff_configuration: super_diff_configuration,
1919
preserve_as_whole_file: preserve_as_whole_file
2020
)
2121
end
@@ -32,15 +32,13 @@ def make_rspec_rails_test_program(test, color_enabled:)
3232
TestPrograms::RSpecRails.new(test, color_enabled: color_enabled)
3333
end
3434

35-
def make_rspec_rails_engine_program(
35+
def make_rspec_rails_engine_with_action_controller_program(
3636
test,
37-
color_enabled:,
38-
combustion_initialize:
37+
color_enabled:
3938
)
40-
TestPrograms::RspecRailsEngine.new(
39+
TestPrograms::RspecRailsEngineWithActionController.new(
4140
test,
42-
color_enabled: color_enabled,
43-
combustion_initialize: combustion_initialize
41+
color_enabled: color_enabled
4442
)
4543
end
4644

spec/support/integration/test_programs/base.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class Base
1313
def initialize(
1414
code,
1515
color_enabled:,
16-
configuration: {},
16+
super_diff_configuration: {},
1717
preserve_as_whole_file: false
1818
)
1919
@code = code.strip
2020
@color_enabled = color_enabled
21-
@configuration = configuration
21+
@super_diff_configuration = super_diff_configuration
2222
@preserve_as_whole_file = preserve_as_whole_file
2323
end
2424

@@ -38,7 +38,7 @@ def test_plan_command
3838

3939
private
4040

41-
attr_reader :code, :configuration
41+
attr_reader :code, :super_diff_configuration
4242

4343
def color_enabled?
4444
@color_enabled
@@ -74,8 +74,8 @@ def command
7474
color_option,
7575
"--no-pry",
7676
tempfile.to_s,
77-
"--configuration",
78-
JSON.generate(configuration)
77+
"--super-diff-configuration",
78+
JSON.generate(super_diff_configuration)
7979
]
8080
else
8181
["rspec", "--options", "/tmp/dummy-rspec-config", tempfile.to_s]
@@ -110,7 +110,7 @@ def program
110110
test_plan = TestPlan.new(
111111
using_outside_of_zeus: true,
112112
color_enabled: #{color_enabled?.inspect},
113-
configuration: #{configuration.inspect}
113+
super_diff_configuration: #{super_diff_configuration.inspect}
114114
)
115115
#{test_plan_prelude}
116116
test_plan.#{test_plan_command}

spec/support/integration/test_programs/rspec_rails_engine.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
module SuperDiff
22
module IntegrationTests
33
module TestPrograms
4-
class RspecRailsEngine < Base
5-
def initialize(*args, combustion_initialize:, **options)
6-
super(*args, **options)
7-
@combustion_initialize = combustion_initialize
8-
end
9-
4+
class RspecRailsEngineWithActionController < Base
105
protected
116

127
def test_plan_prelude
138
<<~PRELUDE.strip
14-
test_plan.boot_rails_engine(
15-
combustion_initialize: #{combustion_initialize.inspect}
16-
)
9+
test_plan.boot
10+
test_plan.boot_rails_engine_with_action_controller
1711
PRELUDE
1812
end
1913

2014
def test_plan_command
2115
"run_rspec_rails_test"
2216
end
23-
24-
private
25-
26-
attr_reader :combustion_initialize
2717
end
2818
end
2919
end

spec/support/shared_examples/elided_diffs.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
make_plain_test_program(
4141
snippet,
4242
color_enabled: color_enabled,
43-
configuration: {
43+
super_diff_configuration: {
4444
diff_elision_enabled: true,
4545
diff_elision_maximum: 3
4646
}
@@ -129,7 +129,7 @@
129129
make_plain_test_program(
130130
snippet,
131131
color_enabled: color_enabled,
132-
configuration: {
132+
super_diff_configuration: {
133133
diff_elision_enabled: false,
134134
diff_elision_maximum: 3
135135
}
@@ -228,7 +228,7 @@
228228
make_plain_test_program(
229229
snippet,
230230
color_enabled: color_enabled,
231-
configuration: {
231+
super_diff_configuration: {
232232
diff_elision_enabled: true,
233233
diff_elision_maximum: 3
234234
}
@@ -318,7 +318,7 @@
318318
make_plain_test_program(
319319
snippet,
320320
color_enabled: color_enabled,
321-
configuration: {
321+
super_diff_configuration: {
322322
diff_elision_enabled: false,
323323
diff_elision_maximum: 3
324324
}
@@ -550,7 +550,7 @@
550550
make_plain_test_program(
551551
snippet,
552552
color_enabled: color_enabled,
553-
configuration: {
553+
super_diff_configuration: {
554554
diff_elision_enabled: true,
555555
diff_elision_maximum: 10
556556
}
@@ -811,7 +811,7 @@
811811
make_plain_test_program(
812812
snippet,
813813
color_enabled: color_enabled,
814-
configuration: {
814+
super_diff_configuration: {
815815
diff_elision_enabled: false,
816816
diff_elision_maximum: 10
817817
}

spec/support/shared_examples/key.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
make_plain_test_program(
2020
snippet,
2121
color_enabled: color_enabled,
22-
configuration: {
22+
super_diff_configuration: {
2323
key_enabled: true
2424
}
2525
)
@@ -80,7 +80,7 @@
8080
make_plain_test_program(
8181
snippet,
8282
color_enabled: color_enabled,
83-
configuration: {
83+
super_diff_configuration: {
8484
key_enabled: false
8585
}
8686
)

support/test_plan.rb

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class TestPlan
1111
def initialize(
1212
using_outside_of_zeus: false,
1313
color_enabled: false,
14-
configuration: {}
14+
super_diff_configuration: {}
1515
)
1616
@using_outside_of_zeus = using_outside_of_zeus
1717
@color_enabled = color_enabled
18-
@configuration = configuration
18+
@super_diff_configuration = super_diff_configuration
1919

2020
@pry_enabled = true
2121
@libraries = []
@@ -76,7 +76,7 @@ def best_available
7676
def boot_active_support
7777
require "active_support"
7878
require "active_support/core_ext/hash/indifferent_access"
79-
rescue LoadError
79+
rescue LoadError => e
8080
# active_support may not be in the Gemfile, so that's okay
8181
puts "Error in TestPlan#boot_active_support: #{e.message}"
8282
end
@@ -110,9 +110,11 @@ def boot_rails
110110
boot_active_record
111111
end
112112

113-
def boot_rails_engine(combustion_initialize: [])
113+
def boot_rails_engine_with_action_controller
114+
boot_active_support
115+
114116
require "combustion"
115-
Combustion.initialize!(*combustion_initialize)
117+
Combustion.initialize!(:action_controller)
116118
end
117119

118120
def run_plain_test
@@ -131,9 +133,12 @@ def run_rspec_rails_test
131133
run_test_with_libraries("super_diff/rspec-rails")
132134
end
133135

136+
alias_method :run_rspec_rails_engine_with_action_controller_test,
137+
:run_rspec_rails_test
138+
134139
private
135140

136-
attr_reader :libraries, :configuration
141+
attr_reader :libraries, :super_diff_configuration
137142

138143
def using_outside_of_zeus?
139144
@using_outside_of_zeus
@@ -165,7 +170,7 @@ def run_test_with_libraries(*libraries)
165170
option_parser.parse! if !using_outside_of_zeus?
166171

167172
SuperDiff.configuration.merge!(
168-
configuration.merge(color_enabled: color_enabled?)
173+
super_diff_configuration.merge(color_enabled: color_enabled?)
169174
)
170175

171176
ENV["DISABLE_PRY"] = "true" if !pry_enabled?
@@ -187,10 +192,12 @@ def option_parser
187192
opts.on("--[no-]pry", "Disable Pry.") { |value| @pry_enabled = value }
188193

189194
opts.on(
190-
"--configuration CONFIG",
195+
"--super-diff-configuration CONFIG",
191196
String,
192197
"Configure SuperDiff."
193-
) { |json| @configuration = JSON.parse(json).transform_keys(&:to_sym) }
198+
) do |json|
199+
@super_diff_configuration = JSON.parse(json).transform_keys(&:to_sym)
200+
end
194201
end
195202
end
196203
end

zeus.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
},
1212
"boot_rails": {
1313
"run_rspec_rails_test": []
14+
},
15+
"boot_rails_engine_with_action_controller": {
16+
"run_rspec_rails_engine_with_action_controller_test": []
1417
}
15-
},
16-
"boot_rails_engine": []
18+
}
1719
}
1820
}

0 commit comments

Comments
 (0)