Skip to content

Commit 4f80db9

Browse files
authored
Revert 2.3 ruby compatibility (#80)
1 parent 6d29947 commit 4f80db9

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ eval_gemfile 'Gemfile.devtools'
66

77
gemspec
88

9+
gem 'backports', '~> 3.15.0', require: false
10+
911
unless ENV['CI']
1012
gem 'byebug', require: false, platforms: :mri
1113
gem 'yard', require: false

lib/dry/cli/utils/files.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'pathname'
44
require 'fileutils'
5+
require 'backports/2.4.0/string/match' if RUBY_VERSION < '2.4'
56

67
module Dry
78
class CLI

spec/integration/single_command_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
end
3838

3939
it 'with option_one' do
40-
output = `baz first_arg --option_one=test2`
40+
output = `baz first_arg --option-one=test2`
4141
expect(output).to eq(
4242
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
4343
"Options: {:option_with_default=>\"test\", :option_one=>\"test2\"}\n"

spec/unit/dry/cli/cli_spec.rb

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,22 @@
6969
)
7070
end
7171

72-
it 'with option_one' do
73-
output = capture_output { cli.call(arguments: %w[first_arg --option_one=test2]) }
72+
it 'with option_one', if: RUBY_VERSION < '2.4' do
73+
output = capture_output { cli.call(arguments: %w[first_arg --option-one=test2]) }
7474
expect(output).to eq(
7575
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
7676
"Options: {:option_with_default=>\"test\", :option_one=>\"test2\"}\n"
7777
)
7878
end
7979

80+
it 'with underscored option_one', if: RUBY_VERSION >= '2.4' do
81+
output = capture_output { cli.call(arguments: %w[first_arg --option_one=test2]) }
82+
expect(output).to eq(
83+
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
84+
"Options: {:option_with_default=>\"test\", :option_one=>\"test2\"}\n"
85+
)
86+
end
87+
8088
it 'with option_one alias' do
8189
output = capture_output { cli.call(arguments: %w[first_arg -1 test2]) }
8290
expect(output).to eq(
@@ -85,14 +93,22 @@
8593
)
8694
end
8795

88-
it 'with boolean_option' do
89-
output = capture_output { cli.call(arguments: %w[first_arg --boolean_option]) }
96+
it 'with boolean_option', if: RUBY_VERSION < '2.4' do
97+
output = capture_output { cli.call(arguments: %w[first_arg --boolean-option]) }
9098
expect(output).to eq(
9199
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
92100
"Options: {:option_with_default=>\"test\", :boolean_option=>true}\n"
93101
)
94102
end
95103

104+
it 'with underscored boolean_option', if: RUBY_VERSION >= '2.4' do
105+
output = capture_output { cli.call(arguments: %w[first_arg --boolean_option]) }
106+
expect(output).to eq(
107+
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
108+
"Options: {:option_with_default=>\"test\", :boolean_option=>true}\n"
109+
)
110+
end
111+
96112
it 'with boolean_option alias' do
97113
output = capture_output { cli.call(arguments: %w[first_arg -b]) }
98114
expect(output).to eq(
@@ -101,14 +117,22 @@
101117
)
102118
end
103119

104-
it 'with option_with_default alias' do
105-
output = capture_output { cli.call(arguments: %w[first_arg --option_with_default=test3]) }
120+
it 'with option_with_default alias', if: RUBY_VERSION < '2.4' do
121+
output = capture_output { cli.call(arguments: %w[first_arg --option-with-default=test3]) }
106122
expect(output).to eq(
107123
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
108124
"Options: {:option_with_default=>\"test3\"}\n"
109125
)
110126
end
111127

128+
it 'with underscoreed option_with_default alias', if: RUBY_VERSION >= '2.4' do
129+
output = capture_output { cli.call(arguments: %w[first_arg --option_with_default=test3]) }
130+
expect(output).to eq(
131+
'mandatory_arg: first_arg. optional_arg: optional_arg. ' \
132+
"Options: {:option_with_default=>\"test3\"}\n"
133+
)
134+
end
135+
112136
it 'with combination of aliases' do
113137
output = capture_output { cli.call(arguments: %w[first_arg -bd test3]) }
114138
expect(output).to eq(

0 commit comments

Comments
 (0)