thor 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.rdoc +8 -0
- data/Gemfile +12 -8
- data/lib/thor.rb +79 -10
- data/lib/thor/actions.rb +13 -13
- data/lib/thor/actions/directory.rb +29 -10
- data/lib/thor/actions/file_manipulation.rb +8 -2
- data/lib/thor/base.rb +24 -11
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +5 -0
- data/lib/thor/group.rb +5 -5
- data/lib/thor/parser/options.rb +63 -25
- data/lib/thor/rake_compat.rb +3 -2
- data/lib/thor/runner.rb +1 -1
- data/lib/thor/shell/basic.rb +16 -16
- data/lib/thor/shell/color.rb +9 -9
- data/lib/thor/shell/html.rb +9 -9
- data/lib/thor/task.rb +2 -2
- data/lib/thor/version.rb +1 -1
- data/spec/actions/create_file_spec.rb +30 -30
- data/spec/actions/create_link_spec.rb +12 -12
- data/spec/actions/directory_spec.rb +34 -27
- data/spec/actions/empty_directory_spec.rb +16 -16
- data/spec/actions/file_manipulation_spec.rb +62 -50
- data/spec/actions/inject_into_file_spec.rb +18 -18
- data/spec/actions_spec.rb +56 -56
- data/spec/base_spec.rb +69 -69
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +19 -14
- data/spec/core_ext/ordered_hash_spec.rb +29 -29
- data/spec/exit_condition_spec.rb +3 -3
- data/spec/fixtures/preserve/script.sh +3 -0
- data/spec/fixtures/script.thor +5 -0
- data/spec/group_spec.rb +55 -55
- data/spec/invocation_spec.rb +26 -26
- data/spec/parser/argument_spec.rb +12 -12
- data/spec/parser/arguments_spec.rb +12 -12
- data/spec/parser/option_spec.rb +47 -47
- data/spec/parser/options_spec.rb +137 -72
- data/spec/rake_compat_spec.rb +11 -11
- data/spec/register_spec.rb +70 -8
- data/spec/runner_spec.rb +38 -38
- data/spec/shell/basic_spec.rb +49 -37
- data/spec/shell/color_spec.rb +13 -13
- data/spec/shell/html_spec.rb +3 -3
- data/spec/shell_spec.rb +7 -7
- data/spec/spec_helper.rb +4 -0
- data/spec/task_spec.rb +11 -11
- data/spec/thor_spec.rb +161 -91
- data/spec/util_spec.rb +42 -42
- data/thor.gemspec +1 -7
- metadata +8 -118
- data/lib/thor/core_ext/dir_escape.rb +0 -0
data/spec/invocation_spec.rb
CHANGED
@@ -4,97 +4,97 @@ require 'thor/base'
|
|
4
4
|
describe Thor::Invocation do
|
5
5
|
describe "#invoke" do
|
6
6
|
it "invokes a task inside another task" do
|
7
|
-
capture(:stdout){ A.new.invoke(:two) }.
|
7
|
+
expect(capture(:stdout) { A.new.invoke(:two) }).to eq("2\n3\n")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "invokes a task just once" do
|
11
|
-
capture(:stdout){ A.new.invoke(:one) }.
|
11
|
+
expect(capture(:stdout) { A.new.invoke(:one) }).to eq("1\n2\n3\n")
|
12
12
|
end
|
13
13
|
|
14
14
|
it "invokes a task just once even if they belongs to different classes" do
|
15
|
-
capture(:stdout){ Defined.new.invoke(:one) }.
|
15
|
+
expect(capture(:stdout) { Defined.new.invoke(:one) }).to eq("1\n2\n3\n4\n5\n")
|
16
16
|
end
|
17
17
|
|
18
18
|
it "invokes a task with arguments" do
|
19
|
-
A.new.invoke(:five, [5]).
|
20
|
-
A.new.invoke(:five, [7]).
|
19
|
+
expect(A.new.invoke(:five, [5])).to be_true
|
20
|
+
expect(A.new.invoke(:five, [7])).to be_false
|
21
21
|
end
|
22
22
|
|
23
23
|
it "invokes the default task if none is given to a Thor class" do
|
24
|
-
content = capture(:stdout){ A.new.invoke("b") }
|
25
|
-
content.
|
26
|
-
content.
|
24
|
+
content = capture(:stdout) { A.new.invoke("b") }
|
25
|
+
expect(content).to match(/Tasks/)
|
26
|
+
expect(content).to match(/LAST_NAME/)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "accepts a class as argument without a task to invoke" do
|
30
|
-
content = capture(:stdout){ A.new.invoke(B) }
|
31
|
-
content.
|
32
|
-
content.
|
30
|
+
content = capture(:stdout) { A.new.invoke(B) }
|
31
|
+
expect(content).to match(/Tasks/)
|
32
|
+
expect(content).to match(/LAST_NAME/)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "accepts a class as argument with a task to invoke" do
|
36
36
|
base = A.new([], :last_name => "Valim")
|
37
|
-
base.invoke(B, :one, ["Jose"]).
|
37
|
+
expect(base.invoke(B, :one, ["Jose"])).to eq("Valim, Jose")
|
38
38
|
end
|
39
39
|
|
40
40
|
it "allows customized options to be given" do
|
41
41
|
base = A.new([], :last_name => "Wrong")
|
42
|
-
base.invoke(B, :one, ["Jose"], :last_name => "Valim").
|
42
|
+
expect(base.invoke(B, :one, ["Jose"], :last_name => "Valim")).to eq("Valim, Jose")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "reparses options in the new class" do
|
46
|
-
A.start(["invoker", "--last-name", "Valim"]).
|
46
|
+
expect(A.start(["invoker", "--last-name", "Valim"])).to eq("Valim, Jose")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "shares initialize options with invoked class" do
|
50
|
-
A.new([], :foo => :bar).invoke("b:two").
|
50
|
+
expect(A.new([], :foo => :bar).invoke("b:two")).to eq({ "foo" => :bar })
|
51
51
|
end
|
52
52
|
|
53
53
|
it "dump configuration values to be used in the invoked class" do
|
54
54
|
base = A.new
|
55
|
-
base.invoke("b:three").shell.
|
55
|
+
expect(base.invoke("b:three").shell).to eq(base.shell)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "allow extra configuration values to be given" do
|
59
59
|
base, shell = A.new, Thor::Base.shell.new
|
60
|
-
base.invoke("b:three", [], {}, :shell => shell).shell.
|
60
|
+
expect(base.invoke("b:three", [], {}, :shell => shell).shell).to eq(shell)
|
61
61
|
end
|
62
62
|
|
63
63
|
it "invokes a Thor::Group and all of its tasks" do
|
64
|
-
capture(:stdout){ A.new.invoke(:c) }.
|
64
|
+
expect(capture(:stdout) { A.new.invoke(:c) }).to eq("1\n2\n3\n")
|
65
65
|
end
|
66
66
|
|
67
67
|
it "does not invoke a Thor::Group twice" do
|
68
68
|
base = A.new
|
69
69
|
silence(:stdout){ base.invoke(:c) }
|
70
|
-
capture(:stdout){ base.invoke(:c) }.
|
70
|
+
expect(capture(:stdout) { base.invoke(:c) }).to be_empty
|
71
71
|
end
|
72
72
|
|
73
73
|
it "does not invoke any of Thor::Group tasks twice" do
|
74
74
|
base = A.new
|
75
75
|
silence(:stdout){ base.invoke(:c) }
|
76
|
-
capture(:stdout){ base.invoke("c:one") }.
|
76
|
+
expect(capture(:stdout) { base.invoke("c:one") }).to be_empty
|
77
77
|
end
|
78
78
|
|
79
79
|
it "raises Thor::UndefinedTaskError if the task can't be found" do
|
80
|
-
|
80
|
+
expect {
|
81
81
|
A.new.invoke("foo:bar")
|
82
|
-
|
82
|
+
}.to raise_error(Thor::UndefinedTaskError)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "raises Thor::UndefinedTaskError if the task can't be found even if all tasks where already executed" do
|
86
86
|
base = C.new
|
87
87
|
silence(:stdout){ base.invoke_all }
|
88
88
|
|
89
|
-
|
89
|
+
expect {
|
90
90
|
base.invoke("foo:bar")
|
91
|
-
|
91
|
+
}.to raise_error(Thor::UndefinedTaskError)
|
92
92
|
end
|
93
93
|
|
94
94
|
it "raises an error if a non Thor class is given" do
|
95
|
-
|
95
|
+
expect {
|
96
96
|
A.new.invoke(Object)
|
97
|
-
|
97
|
+
}.to raise_error(RuntimeError, "Expected Thor class, got Object")
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -9,45 +9,45 @@ describe Thor::Argument do
|
|
9
9
|
|
10
10
|
describe "errors" do
|
11
11
|
it "raises an error if name is not supplied" do
|
12
|
-
|
12
|
+
expect {
|
13
13
|
argument(nil)
|
14
|
-
}.
|
14
|
+
}.to raise_error(ArgumentError, "Argument name can't be nil.")
|
15
15
|
end
|
16
16
|
|
17
17
|
it "raises an error if type is unknown" do
|
18
|
-
|
18
|
+
expect {
|
19
19
|
argument(:task, :type => :unknown)
|
20
|
-
}.
|
20
|
+
}.to raise_error(ArgumentError, "Type :unknown is not valid for arguments.")
|
21
21
|
end
|
22
22
|
|
23
23
|
it "raises an error if argument is required and have default values" do
|
24
|
-
|
24
|
+
expect {
|
25
25
|
argument(:task, :type => :string, :default => "bar", :required => true)
|
26
|
-
}.
|
26
|
+
}.to raise_error(ArgumentError, "An argument cannot be required and have default value.")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "raises an error if enum isn't an array" do
|
30
|
-
|
30
|
+
expect {
|
31
31
|
argument(:task, :type => :string, :enum => "bar")
|
32
|
-
}.
|
32
|
+
}.to raise_error(ArgumentError, "An argument cannot have an enum other than an array.")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#usage" do
|
37
37
|
it "returns usage for string types" do
|
38
|
-
argument(:foo, :type => :string).usage.
|
38
|
+
expect(argument(:foo, :type => :string).usage).to eq("FOO")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns usage for numeric types" do
|
42
|
-
argument(:foo, :type => :numeric).usage.
|
42
|
+
expect(argument(:foo, :type => :numeric).usage).to eq("N")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns usage for array types" do
|
46
|
-
argument(:foo, :type => :array).usage.
|
46
|
+
expect(argument(:foo, :type => :array).usage).to eq("one two three")
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns usage for hash types" do
|
50
|
-
argument(:foo, :type => :hash).usage.
|
50
|
+
expect(argument(:foo, :type => :hash).usage).to eq("key:value")
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -19,48 +19,48 @@ describe Thor::Arguments do
|
|
19
19
|
describe "#parse" do
|
20
20
|
it "parses arguments in the given order" do
|
21
21
|
create :string => nil, :numeric => nil
|
22
|
-
parse("name", "13")["string"].
|
23
|
-
parse("name", "13")["numeric"].
|
22
|
+
expect(parse("name", "13")["string"]).to eq("name")
|
23
|
+
expect(parse("name", "13")["numeric"]).to eq(13)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "accepts hashes" do
|
27
27
|
create :string => nil, :hash => nil
|
28
|
-
parse("product", "title:string", "age:integer")["string"].
|
29
|
-
parse("product", "title:string", "age:integer")["hash"].
|
30
|
-
parse("product", "url:http://www.amazon.com/gp/product/123")["hash"].
|
28
|
+
expect(parse("product", "title:string", "age:integer")["string"]).to eq("product")
|
29
|
+
expect(parse("product", "title:string", "age:integer")["hash"]).to eq({ "title" => "string", "age" => "integer"})
|
30
|
+
expect(parse("product", "url:http://www.amazon.com/gp/product/123")["hash"]).to eq({ "url" => "http://www.amazon.com/gp/product/123" })
|
31
31
|
end
|
32
32
|
|
33
33
|
it "accepts arrays" do
|
34
34
|
create :string => nil, :array => nil
|
35
|
-
parse("product", "title", "age")["string"].
|
36
|
-
parse("product", "title", "age")["array"].
|
35
|
+
expect(parse("product", "title", "age")["string"]).to eq("product")
|
36
|
+
expect(parse("product", "title", "age")["array"]).to eq(%w(title age))
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "with no inputs" do
|
40
40
|
it "and no arguments returns an empty hash" do
|
41
41
|
create
|
42
|
-
parse.
|
42
|
+
expect(parse).to eq({})
|
43
43
|
end
|
44
44
|
|
45
45
|
it "and required arguments raises an error" do
|
46
46
|
create :string => nil, :numeric => nil
|
47
|
-
|
47
|
+
expect{ parse }.to raise_error(Thor::RequiredArgumentMissingError, "No value provided for required arguments 'string', 'numeric'")
|
48
48
|
end
|
49
49
|
|
50
50
|
it "and default arguments returns default values" do
|
51
51
|
create :string => "name", :numeric => 13
|
52
|
-
parse.
|
52
|
+
expect(parse).to eq({ "string" => "name", "numeric" => 13 })
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
it "returns the input if it's already parsed" do
|
57
57
|
create :string => nil, :hash => nil, :array => nil, :numeric => nil
|
58
|
-
parse("", 0, {}, []).
|
58
|
+
expect(parse("", 0, {}, [])).to eq({ "string" => "", "numeric" => 0, "hash" => {}, "array" => [] })
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns the default value if none is provided" do
|
62
62
|
create :string => "foo", :numeric => 3.0
|
63
|
-
parse("bar").
|
63
|
+
expect(parse("bar")).to eq({ "string" => "bar", "numeric" => 3.0 })
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
data/spec/parser/option_spec.rb
CHANGED
@@ -15,187 +15,187 @@ describe Thor::Option do
|
|
15
15
|
describe "with value as a symbol" do
|
16
16
|
describe "and symbol is a valid type" do
|
17
17
|
it "has type equals to the symbol" do
|
18
|
-
parse(:foo, :string).type.
|
19
|
-
parse(:foo, :numeric).type.
|
18
|
+
expect(parse(:foo, :string).type).to eq(:string)
|
19
|
+
expect(parse(:foo, :numeric).type).to eq(:numeric)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "has not default value" do
|
23
|
-
parse(:foo, :string).default.
|
24
|
-
parse(:foo, :numeric).default.
|
23
|
+
expect(parse(:foo, :string).default).to be_nil
|
24
|
+
expect(parse(:foo, :numeric).default).to be_nil
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "equals to :required" do
|
29
29
|
it "has type equals to :string" do
|
30
|
-
parse(:foo, :required).type.
|
30
|
+
expect(parse(:foo, :required).type).to eq(:string)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "has no default value" do
|
34
|
-
parse(:foo, :required).default.
|
34
|
+
expect(parse(:foo, :required).default).to be_nil
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe "and symbol is not a reserved key" do
|
39
39
|
it "has type equals to :string" do
|
40
|
-
parse(:foo, :bar).type.
|
40
|
+
expect(parse(:foo, :bar).type).to eq(:string)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "has no default value" do
|
44
|
-
parse(:foo, :bar).default.
|
44
|
+
expect(parse(:foo, :bar).default).to be_nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "with value as hash" do
|
50
50
|
it "has default type :hash" do
|
51
|
-
parse(:foo, :a => :b).type.
|
51
|
+
expect(parse(:foo, :a => :b).type).to eq(:hash)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "has default value equals to the hash" do
|
55
|
-
parse(:foo, :a => :b).default.
|
55
|
+
expect(parse(:foo, :a => :b).default).to eq({ :a => :b })
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "with value as array" do
|
60
60
|
it "has default type :array" do
|
61
|
-
parse(:foo, [:a, :b]).type.
|
61
|
+
expect(parse(:foo, [:a, :b]).type).to eq(:array)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "has default value equals to the array" do
|
65
|
-
parse(:foo, [:a, :b]).default.
|
65
|
+
expect(parse(:foo, [:a, :b]).default).to eq([:a, :b])
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "with value as string" do
|
70
70
|
it "has default type :string" do
|
71
|
-
parse(:foo, "bar").type.
|
71
|
+
expect(parse(:foo, "bar").type).to eq(:string)
|
72
72
|
end
|
73
73
|
|
74
74
|
it "has default value equals to the string" do
|
75
|
-
parse(:foo, "bar").default.
|
75
|
+
expect(parse(:foo, "bar").default).to eq("bar")
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "with value as numeric" do
|
80
80
|
it "has default type :numeric" do
|
81
|
-
parse(:foo, 2.0).type.
|
81
|
+
expect(parse(:foo, 2.0).type).to eq(:numeric)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "has default value equals to the numeric" do
|
85
|
-
parse(:foo, 2.0).default.
|
85
|
+
expect(parse(:foo, 2.0).default).to eq(2.0)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
89
|
describe "with value as boolean" do
|
90
90
|
it "has default type :boolean" do
|
91
|
-
parse(:foo, true).type.
|
92
|
-
parse(:foo, false).type.
|
91
|
+
expect(parse(:foo, true).type).to eq(:boolean)
|
92
|
+
expect(parse(:foo, false).type).to eq(:boolean)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "has default value equals to the boolean" do
|
96
|
-
parse(:foo, true).default.
|
97
|
-
parse(:foo, false).default.
|
96
|
+
expect(parse(:foo, true).default).to eq(true)
|
97
|
+
expect(parse(:foo, false).default).to eq(false)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe "with key as a symbol" do
|
102
102
|
it "sets the name equals to the key" do
|
103
|
-
parse(:foo, true).name.
|
103
|
+
expect(parse(:foo, true).name).to eq("foo")
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
describe "with key as an array" do
|
108
108
|
it "sets the first items in the array to the name" do
|
109
|
-
parse([:foo, :bar, :baz], true).name.
|
109
|
+
expect(parse([:foo, :bar, :baz], true).name).to eq("foo")
|
110
110
|
end
|
111
111
|
|
112
112
|
it "sets all other items as aliases" do
|
113
|
-
parse([:foo, :bar, :baz], true).aliases.
|
113
|
+
expect(parse([:foo, :bar, :baz], true).aliases).to eq([:bar, :baz])
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
it "returns the switch name" do
|
119
|
-
option("foo").switch_name.
|
120
|
-
option("--foo").switch_name.
|
119
|
+
expect(option("foo").switch_name).to eq("--foo")
|
120
|
+
expect(option("--foo").switch_name).to eq("--foo")
|
121
121
|
end
|
122
122
|
|
123
123
|
it "returns the human name" do
|
124
|
-
option("foo").human_name.
|
125
|
-
option("--foo").human_name.
|
124
|
+
expect(option("foo").human_name).to eq("foo")
|
125
|
+
expect(option("--foo").human_name).to eq("foo")
|
126
126
|
end
|
127
127
|
|
128
128
|
it "converts underscores to dashes" do
|
129
|
-
option("foo_bar").switch_name.
|
129
|
+
expect(option("foo_bar").switch_name).to eq("--foo-bar")
|
130
130
|
end
|
131
131
|
|
132
132
|
it "can be required and have default values" do
|
133
133
|
option = option("foo", :required => true, :type => :string, :default => "bar")
|
134
|
-
option.default.
|
135
|
-
option.
|
134
|
+
expect(option.default).to eq("bar")
|
135
|
+
expect(option).to be_required
|
136
136
|
end
|
137
137
|
|
138
138
|
it "cannot be required and have type boolean" do
|
139
|
-
|
139
|
+
expect {
|
140
140
|
option("foo", :required => true, :type => :boolean)
|
141
|
-
}.
|
141
|
+
}.to raise_error(ArgumentError, "An option cannot be boolean and required.")
|
142
142
|
end
|
143
143
|
|
144
144
|
it "allows type predicates" do
|
145
|
-
parse(:foo, :string).
|
146
|
-
parse(:foo, :boolean).
|
147
|
-
parse(:foo, :numeric).
|
145
|
+
expect(parse(:foo, :string)).to be_string
|
146
|
+
expect(parse(:foo, :boolean)).to be_boolean
|
147
|
+
expect(parse(:foo, :numeric)).to be_numeric
|
148
148
|
end
|
149
149
|
|
150
150
|
it "raises an error on method missing" do
|
151
|
-
|
151
|
+
expect {
|
152
152
|
parse(:foo, :string).unknown?
|
153
|
-
}.
|
153
|
+
}.to raise_error(NoMethodError)
|
154
154
|
end
|
155
155
|
|
156
156
|
describe "#usage" do
|
157
157
|
|
158
158
|
it "returns usage for string types" do
|
159
|
-
parse(:foo, :string).usage.
|
159
|
+
expect(parse(:foo, :string).usage).to eq("[--foo=FOO]")
|
160
160
|
end
|
161
161
|
|
162
162
|
it "returns usage for numeric types" do
|
163
|
-
parse(:foo, :numeric).usage.
|
163
|
+
expect(parse(:foo, :numeric).usage).to eq("[--foo=N]")
|
164
164
|
end
|
165
165
|
|
166
166
|
it "returns usage for array types" do
|
167
|
-
parse(:foo, :array).usage.
|
167
|
+
expect(parse(:foo, :array).usage).to eq("[--foo=one two three]")
|
168
168
|
end
|
169
169
|
|
170
170
|
it "returns usage for hash types" do
|
171
|
-
parse(:foo, :hash).usage.
|
171
|
+
expect(parse(:foo, :hash).usage).to eq("[--foo=key:value]")
|
172
172
|
end
|
173
173
|
|
174
174
|
it "returns usage for boolean types" do
|
175
|
-
parse(:foo, :boolean).usage.
|
175
|
+
expect(parse(:foo, :boolean).usage).to eq("[--foo]")
|
176
176
|
end
|
177
177
|
|
178
178
|
it "uses padding when no aliases is given" do
|
179
|
-
parse(:foo, :boolean).usage(4).
|
179
|
+
expect(parse(:foo, :boolean).usage(4)).to eq(" [--foo]")
|
180
180
|
end
|
181
181
|
|
182
182
|
it "uses banner when supplied" do
|
183
|
-
option(:foo, :required => false, :type => :string, :banner => "BAR").usage.
|
183
|
+
expect(option(:foo, :required => false, :type => :string, :banner => "BAR").usage).to eq("[--foo=BAR]")
|
184
184
|
end
|
185
185
|
|
186
186
|
it "checkes when banner is an empty string" do
|
187
|
-
option(:foo, :required => false, :type => :string, :banner => "").usage.
|
187
|
+
expect(option(:foo, :required => false, :type => :string, :banner => "").usage).to eq("[--foo]")
|
188
188
|
end
|
189
189
|
|
190
190
|
describe "with required values" do
|
191
191
|
it "does not show the usage between brackets" do
|
192
|
-
parse(:foo, :required).usage.
|
192
|
+
expect(parse(:foo, :required).usage).to eq("--foo=FOO")
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
196
|
describe "with aliases" do
|
197
197
|
it "does not show the usage between brackets" do
|
198
|
-
parse([:foo, "-f", "-b"], :required).usage.
|
198
|
+
expect(parse([:foo, "-f", "-b"], :required).usage).to eq("-f, -b, --foo=FOO")
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|