Skip to content

Commit 4948914

Browse files
authored
Add support for Ruby 3.4 (#148)
1 parent 04947f2 commit 4948914

File tree

10 files changed

+344
-101
lines changed

10 files changed

+344
-101
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
ruby:
29+
- "3.4"
2930
- "3.3"
3031
- "3.2"
3132
- "3.1"
32-
- "3.0"
3333
include:
3434
- ruby: "3.2"
3535
coverage: "true"

spec/integration/inherited_commands_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@
1818

1919
it "works for subclasses" do
2020
output = `based subrun application_name command_to_run`
21-
expect(output).to eq(
22-
"Run - App: application_name - Command: command_to_run - Options: {:verbosity=>\"INFO\"}\n"
23-
)
21+
22+
if RUBY_VERSION < "3.4"
23+
expect(output).to eq(
24+
"Run - App: application_name - Command: command_to_run - Options: {:verbosity=>\"INFO\"}\n"
25+
)
26+
else
27+
expect(output).to eq(
28+
"Run - App: application_name - Command: command_to_run - Options: {verbosity: \"INFO\"}\n"
29+
)
30+
end
2431
end
2532
end

spec/integration/inline_spec.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@
3333

3434
it "with underscored option_one" do
3535
output = `inline first_arg -1 test2 -bd test3`
36-
expect(output).to eq(
37-
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
38-
'Options: {:option_with_default=>"test3", :option_one=>"test2", :boolean_option=>true}' \
39-
"\n"
40-
)
36+
37+
if RUBY_VERSION < "3.4"
38+
expect(output).to eq(
39+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
40+
'Options: {:option_with_default=>"test3", :option_one=>"test2", :boolean_option=>true}' \
41+
"\n"
42+
)
43+
else
44+
expect(output).to eq(
45+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
46+
'Options: {option_with_default: "test3", option_one: "test2", boolean_option: true}' \
47+
"\n"
48+
)
49+
end
4150
end
4251
end
4352
end

spec/integration/single_command_spec.rb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,34 @@
4040

4141
it "with option_one" do
4242
output = `baz first_arg --option-one=test2`
43-
expect(output).to eq(
44-
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
45-
"Options: {:option_with_default=>\"test\", :option_one=>\"test2\"}\n"
46-
)
43+
44+
if RUBY_VERSION < "3.4"
45+
expect(output).to eq(
46+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
47+
"Options: {:option_with_default=>\"test\", :option_one=>\"test2\"}\n"
48+
)
49+
else
50+
expect(output).to eq(
51+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
52+
"Options: {option_with_default: \"test\", option_one: \"test2\"}\n"
53+
)
54+
end
4755
end
4856

4957
it "with combination of aliases" do
5058
output = `baz first_arg -bd test3`
51-
expect(output).to eq(
52-
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
53-
"Options: {:option_with_default=>\"test3\", :boolean_option=>true}\n"
54-
)
59+
60+
if RUBY_VERSION < "3.4"
61+
expect(output).to eq(
62+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
63+
"Options: {:option_with_default=>\"test3\", :boolean_option=>true}\n"
64+
)
65+
else
66+
expect(output).to eq(
67+
"mandatory_arg: first_arg. optional_arg: optional_arg. " \
68+
"Options: {option_with_default: \"test3\", boolean_option: true}\n"
69+
)
70+
end
5571
end
5672
end
5773

spec/integration/third_party_gems_spec.rb

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@
44
it "allows to add callbacks as a block" do
55
output = `foo callbacks . --url=https://hanamirb.test`
66

7-
expected = <<~OUTPUT
8-
before command callback Foo::Webpack::CLI::CallbacksCommand {:url=>"https://hanamirb.test", :dir=>"."}
9-
before callback (class), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
10-
before callback (object), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
11-
dir: ., url: "https://hanamirb.test"
12-
after command callback Foo::Webpack::CLI::CallbacksCommand {:url=>"https://hanamirb.test", :dir=>"."}
13-
after callback (class), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
14-
after callback (object), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
15-
OUTPUT
7+
if RUBY_VERSION < "3.4"
8+
expected = <<~OUTPUT
9+
before command callback Foo::Webpack::CLI::CallbacksCommand {:url=>"https://hanamirb.test", :dir=>"."}
10+
before callback (class), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
11+
before callback (object), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
12+
dir: ., url: "https://hanamirb.test"
13+
after command callback Foo::Webpack::CLI::CallbacksCommand {:url=>"https://hanamirb.test", :dir=>"."}
14+
after callback (class), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
15+
after callback (object), 2 arg(s): {:url=>"https://hanamirb.test", :dir=>"."}
16+
OUTPUT
17+
else
18+
expected = <<~OUTPUT
19+
before command callback Foo::Webpack::CLI::CallbacksCommand {url: "https://hanamirb.test", dir: "."}
20+
before callback (class), 2 arg(s): {url: "https://hanamirb.test", dir: "."}
21+
before callback (object), 2 arg(s): {url: "https://hanamirb.test", dir: "."}
22+
dir: ., url: "https://hanamirb.test"
23+
after command callback Foo::Webpack::CLI::CallbacksCommand {url: "https://hanamirb.test", dir: "."}
24+
after callback (class), 2 arg(s): {url: "https://hanamirb.test", dir: "."}
25+
after callback (object), 2 arg(s): {url: "https://hanamirb.test", dir: "."}
26+
OUTPUT
27+
end
1628
expect(output).to eq(expected)
1729
end
1830
end

spec/support/shared_examples/commands.rb

Lines changed: 88 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,84 @@
2929
context "works with params" do
3030
it "without params" do
3131
output = capture_output { cli.call(arguments: ["server"]) }
32-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
32+
33+
if RUBY_VERSION < "3.4"
34+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
35+
else
36+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"]}\n")
37+
end
3338
end
3439

3540
it "a param using space" do
3641
output = capture_output { cli.call(arguments: %w[server --server thin]) }
37-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :server=>\"thin\"}\n")
42+
43+
if RUBY_VERSION < "3.4"
44+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :server=>\"thin\"}\n")
45+
else
46+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"], server: \"thin\"}\n")
47+
end
3848
end
3949

4050
it "a param using equal sign" do
4151
output = capture_output { cli.call(arguments: %w[server --host=localhost]) }
42-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :host=>\"localhost\"}\n")
52+
53+
if RUBY_VERSION < "3.4"
54+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :host=>\"localhost\"}\n")
55+
else
56+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"], host: \"localhost\"}\n")
57+
end
4358
end
4459

45-
it "a param using alias" do
46-
output = capture_output { cli.call(arguments: %w[options-with-aliases -u test]) }
47-
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
60+
context "with aliases" do
61+
it "includes a space" do
62+
output = capture_output { cli.call(arguments: %w[options-with-aliases -u test]) }
4863

49-
output = capture_output { cli.call(arguments: %w[options-with-aliases -utest]) }
50-
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
64+
if RUBY_VERSION < "3.4"
65+
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
66+
else
67+
expect(output).to eq("options with aliases - {opt: false, url: \"test\"}\n")
68+
end
69+
end
5170

52-
output = capture_output { cli.call(arguments: %w[options-with-aliases -f -u test]) }
53-
expect(output).to eq("options with aliases - {:opt=>false, :flag=>true, :url=>\"test\"}\n")
71+
it "doesn't include a space" do
72+
output = capture_output { cli.call(arguments: %w[options-with-aliases -utest]) }
73+
74+
if RUBY_VERSION < "3.4"
75+
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
76+
else
77+
expect(output).to eq("options with aliases - {opt: false, url: \"test\"}\n")
78+
end
79+
end
80+
81+
it "has multiple aliases" do
82+
output = capture_output { cli.call(arguments: %w[options-with-aliases -f -u test]) }
83+
84+
if RUBY_VERSION < "3.4"
85+
expect(output).to eq("options with aliases - {:opt=>false, :flag=>true, :url=>\"test\"}\n")
86+
else
87+
expect(output).to eq("options with aliases - {opt: false, flag: true, url: \"test\"}\n")
88+
end
89+
end
5490

55-
output = capture_output { cli.call(arguments: %w[options-with-aliases -o]) }
56-
expect(output).to eq("options with aliases - {:opt=>true}\n")
91+
it "uses an alias to override a default value" do
92+
output = capture_output { cli.call(arguments: %w[options-with-aliases -o]) }
5793

58-
output = capture_output { cli.call(arguments: %w[options-with-aliases -of]) }
59-
expect(output).to eq("options with aliases - {:opt=>true, :flag=>true}\n")
94+
if RUBY_VERSION < "3.4"
95+
expect(output).to eq("options with aliases - {:opt=>true}\n")
96+
else
97+
expect(output).to eq("options with aliases - {opt: true}\n")
98+
end
99+
end
100+
101+
it "uses an alias to override a default value, combined with a flag alias" do
102+
output = capture_output { cli.call(arguments: %w[options-with-aliases -of]) }
103+
104+
if RUBY_VERSION < "3.4"
105+
expect(output).to eq("options with aliases - {:opt=>true, :flag=>true}\n")
106+
else
107+
expect(output).to eq("options with aliases - {opt: true, flag: true}\n")
108+
end
109+
end
60110
end
61111

62112
it "a param with unknown param" do
@@ -66,18 +116,38 @@
66116

67117
it "with boolean param" do
68118
output = capture_output { cli.call(arguments: ["server"]) }
69-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
119+
120+
if RUBY_VERSION < "3.4"
121+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
122+
else
123+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"]}\n")
124+
end
70125

71126
output = capture_output { cli.call(arguments: %w[server --no-code-reloading]) }
72-
expect(output).to eq("server - {:code_reloading=>false, :deps=>[\"dep1\", \"dep2\"]}\n")
127+
128+
if RUBY_VERSION < "3.4"
129+
expect(output).to eq("server - {:code_reloading=>false, :deps=>[\"dep1\", \"dep2\"]}\n")
130+
else
131+
expect(output).to eq("server - {code_reloading: false, deps: [\"dep1\", \"dep2\"]}\n")
132+
end
73133
end
74134

75135
it "with flag param" do
76136
output = capture_output { cli.call(arguments: ["server"]) }
77-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
137+
138+
if RUBY_VERSION < "3.4"
139+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
140+
else
141+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"]}\n")
142+
end
78143

79144
output = capture_output { cli.call(arguments: %w[server --quiet]) }
80-
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :quiet=>true}\n")
145+
146+
if RUBY_VERSION < "3.4"
147+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :quiet=>true}\n")
148+
else
149+
expect(output).to eq("server - {code_reloading: true, deps: [\"dep1\", \"dep2\"], quiet: true}\n")
150+
end
81151
end
82152

83153
context "with array param" do

spec/support/shared_examples/inherited_commands.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,26 +143,46 @@
143143
context "with inherited options" do
144144
it "run has default verbosity_level" do
145145
output = capture_output { cli.call(arguments: %w[i run application_name command_name]) }
146-
expect(output).to include('Options: {:verbosity=>"INFO"}')
146+
147+
if RUBY_VERSION < "3.4"
148+
expect(output).to include('Options: {:verbosity=>"INFO"}')
149+
else
150+
expect(output).to include('Options: {verbosity: "INFO"}')
151+
end
147152
end
148153

149154
it "subrun has default verbosity_level too" do
150155
output = capture_output { cli.call(arguments: %w[i subrun application_name command_name]) }
151-
expect(output).to include('Options: {:verbosity=>"INFO"}')
156+
157+
if RUBY_VERSION < "3.4"
158+
expect(output).to include('Options: {:verbosity=>"INFO"}')
159+
else
160+
expect(output).to include('Options: {verbosity: "INFO"}')
161+
end
152162
end
153163

154164
it "addons has verbosity_level set to debug" do
155165
output = capture_output do
156166
cli.call(arguments: %w[i addons application_name --verbosity=DEBUG])
157167
end
158-
expect(output).to include("Options: {:verbosity=>\"DEBUG\", :json=>false}")
168+
169+
if RUBY_VERSION < "3.4"
170+
expect(output).to include("Options: {:verbosity=>\"DEBUG\", :json=>false}")
171+
else
172+
expect(output).to include("Options: {verbosity: \"DEBUG\", json: false}")
173+
end
159174
end
160175

161176
it "logs has verbosity_level set to WARNING" do
162177
output = capture_output do
163178
cli.call(arguments: %w[i logs application_name --verbosity=WARNING])
164179
end
165-
expect(output).to include("Options: {:verbosity=>\"WARNING\"}")
180+
181+
if RUBY_VERSION < "3.4"
182+
expect(output).to include("Options: {:verbosity=>\"WARNING\"}")
183+
else
184+
expect(output).to include("Options: {verbosity: \"WARNING\"}")
185+
end
166186
end
167187
end
168188

0 commit comments

Comments
 (0)