thor 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,36 +3,36 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe Thor::Group do
4
4
  describe "task" do
5
5
  it "allows to use private methods from parent class as tasks" do
6
- ChildGroup.start.must == ["bar", "foo", "baz"]
7
- ChildGroup.new.baz("bar").must == "bar"
6
+ ChildGroup.start.should == ["bar", "foo", "baz"]
7
+ ChildGroup.new.baz("bar").should == "bar"
8
8
  end
9
9
  end
10
10
 
11
11
  describe "#start" do
12
12
  it "invokes all the tasks under the Thor group" do
13
- MyCounter.start(["1", "2", "--third", "3"]).must == [ 1, 2, 3 ]
13
+ MyCounter.start(["1", "2", "--third", "3"]).should == [ 1, 2, 3 ]
14
14
  end
15
15
 
16
16
  it "uses argument default value" do
17
- MyCounter.start(["1", "--third", "3"]).must == [ 1, 2, 3 ]
17
+ MyCounter.start(["1", "--third", "3"]).should == [ 1, 2, 3 ]
18
18
  end
19
19
 
20
20
  it "invokes all the tasks in the Thor group and his parents" do
21
- BrokenCounter.start(["1", "2", "--third", "3"]).must == [ nil, 2, 3, false, 5 ]
21
+ BrokenCounter.start(["1", "2", "--third", "3"]).should == [ nil, 2, 3, false, 5 ]
22
22
  end
23
23
 
24
24
  it "raises an error if a required argument is added after a non-required" do
25
25
  lambda {
26
26
  MyCounter.argument(:foo, :type => :string)
27
- }.must raise_error(ArgumentError, 'You cannot have "foo" as required argument after the non-required argument "second".')
27
+ }.should raise_error(ArgumentError, 'You cannot have "foo" as required argument after the non-required argument "second".')
28
28
  end
29
29
 
30
30
  it "raises when an exception happens within the task call" do
31
- lambda { BrokenCounter.start(["1", "2", "--fail"]) }.must raise_error
31
+ lambda { BrokenCounter.start(["1", "2", "--fail"]) }.should raise_error
32
32
  end
33
33
 
34
34
  it "raises an error when a Thor group task expects arguments" do
35
- lambda { WhinyGenerator.start }.must raise_error(ArgumentError, /Are you sure it has arity equals to 0\?/)
35
+ lambda { WhinyGenerator.start }.should raise_error(ArgumentError, /Are you sure it has arity equals to 0\?/)
36
36
  end
37
37
 
38
38
  it "invokes help message if any of the shortcuts is given" do
@@ -43,15 +43,15 @@ describe Thor::Group do
43
43
 
44
44
  describe "#desc" do
45
45
  it "sets the description for a given class" do
46
- MyCounter.desc.must == "Description:\n This generator runs three tasks: one, two and three.\n"
46
+ MyCounter.desc.should == "Description:\n This generator runs three tasks: one, two and three.\n"
47
47
  end
48
48
 
49
49
  it "can be inherited" do
50
- BrokenCounter.desc.must == "Description:\n This generator runs three tasks: one, two and three.\n"
50
+ BrokenCounter.desc.should == "Description:\n This generator runs three tasks: one, two and three.\n"
51
51
  end
52
52
 
53
53
  it "can be nil" do
54
- WhinyGenerator.desc.must be_nil
54
+ WhinyGenerator.desc.should be_nil
55
55
  end
56
56
  end
57
57
 
@@ -61,17 +61,17 @@ describe Thor::Group do
61
61
  end
62
62
 
63
63
  it "provides usage information" do
64
- @content.must =~ /my_counter N \[N\]/
64
+ @content.should =~ /my_counter N \[N\]/
65
65
  end
66
66
 
67
67
  it "shows description" do
68
- @content.must =~ /Description:/
69
- @content.must =~ /This generator runs three tasks: one, two and three./
68
+ @content.should =~ /Description:/
69
+ @content.should =~ /This generator runs three tasks: one, two and three./
70
70
  end
71
71
 
72
72
  it "shows options information" do
73
- @content.must =~ /Options/
74
- @content.must =~ /\[\-\-third=THREE\]/
73
+ @content.should =~ /Options/
74
+ @content.should =~ /\[\-\-third=THREE\]/
75
75
  end
76
76
  end
77
77
 
@@ -81,28 +81,28 @@ describe Thor::Group do
81
81
  end
82
82
 
83
83
  it "allows to invoke a class from the class binding" do
84
- @content.must =~ /1\n2\n3\n4\n5\n/
84
+ @content.should =~ /1\n2\n3\n4\n5\n/
85
85
  end
86
86
 
87
87
  it "shows invocation information to the user" do
88
- @content.must =~ /invoke Defined/
88
+ @content.should =~ /invoke Defined/
89
89
  end
90
90
 
91
91
  it "uses padding on status generated by the invoked class" do
92
- @content.must =~ /finished counting/
92
+ @content.should =~ /finished counting/
93
93
  end
94
94
 
95
95
  it "allows invocation to be configured with blocks" do
96
96
  capture(:stdout) do
97
- F.start.must == ["Valim, Jose"]
97
+ F.start.should == ["Valim, Jose"]
98
98
  end
99
99
  end
100
100
 
101
101
  it "shows invoked options on help" do
102
102
  content = capture(:stdout){ E.help(Thor::Base.shell.new) }
103
- content.must =~ /Defined options:/
104
- content.must =~ /\[--unused\]/
105
- content.must =~ /# This option has no use/
103
+ content.should =~ /Defined options:/
104
+ content.should =~ /\[--unused\]/
105
+ content.should =~ /# This option has no use/
106
106
  end
107
107
  end
108
108
 
@@ -113,36 +113,36 @@ describe Thor::Group do
113
113
  end
114
114
 
115
115
  it "allows to invoke a class from the class binding by a default option" do
116
- @content.must =~ /1\n2\n3\n4\n5\n/
116
+ @content.should =~ /1\n2\n3\n4\n5\n/
117
117
  end
118
118
 
119
119
  it "does not invoke if the option is nil" do
120
- capture(:stdout){ G.start(["--skip-invoked"]) }.must_not =~ /invoke/
120
+ capture(:stdout){ G.start(["--skip-invoked"]) }.should_not =~ /invoke/
121
121
  end
122
122
 
123
123
  it "prints a message if invocation cannot be found" do
124
124
  content = capture(:stdout){ G.start(["--invoked", "unknown"]) }
125
- content.must =~ /error unknown \[not found\]/
125
+ content.should =~ /error unknown \[not found\]/
126
126
  end
127
127
 
128
128
  it "allows to invoke a class from the class binding by the given option" do
129
129
  content = capture(:stdout){ G.start(["--invoked", "e"]) }
130
- content.must =~ /invoke e/
130
+ content.should =~ /invoke e/
131
131
  end
132
132
 
133
133
  it "shows invocation information to the user" do
134
- @content.must =~ /invoke defined/
134
+ @content.should =~ /invoke defined/
135
135
  end
136
136
 
137
137
  it "uses padding on status generated by the invoked class" do
138
- @content.must =~ /finished counting/
138
+ @content.should =~ /finished counting/
139
139
  end
140
140
 
141
141
  it "shows invoked options on help" do
142
142
  content = capture(:stdout){ G.help(Thor::Base.shell.new) }
143
- content.must =~ /defined options:/
144
- content.must =~ /\[--unused\]/
145
- content.must =~ /# This option has no use/
143
+ content.should =~ /defined options:/
144
+ content.should =~ /\[--unused\]/
145
+ content.should =~ /# This option has no use/
146
146
  end
147
147
  end
148
148
 
@@ -152,26 +152,26 @@ describe Thor::Group do
152
152
  end
153
153
 
154
154
  it "allows to invoke a class from the class binding by a default option" do
155
- @content.must =~ /1\n2\n3\n4\n5\n/
155
+ @content.should =~ /1\n2\n3\n4\n5\n/
156
156
  end
157
157
 
158
158
  it "does not invoke if the option is false" do
159
- capture(:stdout){ H.start(["--no-defined"]) }.must_not =~ /invoke/
159
+ capture(:stdout){ H.start(["--no-defined"]) }.should_not =~ /invoke/
160
160
  end
161
161
 
162
162
  it "shows invocation information to the user" do
163
- @content.must =~ /invoke defined/
163
+ @content.should =~ /invoke defined/
164
164
  end
165
165
 
166
166
  it "uses padding on status generated by the invoked class" do
167
- @content.must =~ /finished counting/
167
+ @content.should =~ /finished counting/
168
168
  end
169
169
 
170
170
  it "shows invoked options on help" do
171
171
  content = capture(:stdout){ H.help(Thor::Base.shell.new) }
172
- content.must =~ /defined options:/
173
- content.must =~ /\[--unused\]/
174
- content.must =~ /# This option has no use/
172
+ content.should =~ /defined options:/
173
+ content.should =~ /\[--unused\]/
174
+ content.should =~ /# This option has no use/
175
175
  end
176
176
  end
177
177
  end
@@ -4,82 +4,82 @@ 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) }.must == "2\n3\n"
7
+ capture(:stdout){ A.new.invoke(:two) }.should == "2\n3\n"
8
8
  end
9
9
 
10
10
  it "invokes a task just once" do
11
- capture(:stdout){ A.new.invoke(:one) }.must == "1\n2\n3\n"
11
+ capture(:stdout){ A.new.invoke(:one) }.should == "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) }.must == "1\n2\n3\n4\n5\n"
15
+ capture(:stdout){ Defined.new.invoke(:one) }.should == "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]).must be_true
20
- A.new.invoke(:five, [7]).must be_false
19
+ A.new.invoke(:five, [5]).should be_true
20
+ A.new.invoke(:five, [7]).should be_false
21
21
  end
22
22
 
23
23
  it "invokes the default task if none is given to a Thor class" do
24
24
  content = capture(:stdout){ A.new.invoke("b") }
25
- content.must =~ /Tasks/
26
- content.must =~ /LAST_NAME/
25
+ content.should =~ /Tasks/
26
+ content.should =~ /LAST_NAME/
27
27
  end
28
28
 
29
29
  it "accepts a class as argument without a task to invoke" do
30
30
  content = capture(:stdout){ A.new.invoke(B) }
31
- content.must =~ /Tasks/
32
- content.must =~ /LAST_NAME/
31
+ content.should =~ /Tasks/
32
+ content.should =~ /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"]).must == "Valim, Jose"
37
+ base.invoke(B, :one, ["Jose"]).should == "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").must == "Valim, Jose"
42
+ base.invoke(B, :one, ["Jose"], :last_name => "Valim").should == "Valim, Jose"
43
43
  end
44
44
 
45
45
  it "reparses options in the new class" do
46
- A.start(["invoker", "--last-name", "Valim"]).must == "Valim, Jose"
46
+ A.start(["invoker", "--last-name", "Valim"]).should == "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").must == { "foo" => :bar }
50
+ A.new([], :foo => :bar).invoke("b:two").should == { "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.must == base.shell
55
+ base.invoke("b:three").shell.should == 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.must == shell
60
+ base.invoke("b:three", [], {}, :shell => shell).shell.should == 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) }.must == "1\n2\n3\n"
64
+ capture(:stdout){ A.new.invoke(:c) }.should == "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) }.must be_empty
70
+ capture(:stdout){ base.invoke(:c) }.should 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") }.must be_empty
76
+ capture(:stdout){ base.invoke("c:one") }.should be_empty
77
77
  end
78
78
 
79
79
  it "raises Thor::UndefinedTaskError if the task can't be found" do
80
80
  lambda do
81
81
  A.new.invoke("foo:bar")
82
- end.must raise_error(Thor::UndefinedTaskError)
82
+ end.should 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
@@ -88,13 +88,13 @@ describe Thor::Invocation do
88
88
 
89
89
  lambda do
90
90
  base.invoke("foo:bar")
91
- end.must raise_error(Thor::UndefinedTaskError)
91
+ end.should 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
  lambda do
96
96
  A.new.invoke(Object)
97
- end.must raise_error(RuntimeError, "Expected Thor class, got Object")
97
+ end.should raise_error(RuntimeError, "Expected Thor class, got Object")
98
98
  end
99
99
  end
100
100
  end
@@ -11,37 +11,37 @@ describe Thor::Argument do
11
11
  it "raises an error if name is not supplied" do
12
12
  lambda {
13
13
  argument(nil)
14
- }.must raise_error(ArgumentError, "Argument name can't be nil.")
14
+ }.should 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
  lambda {
19
19
  argument(:task, :unknown)
20
- }.must raise_error(ArgumentError, "Type :unknown is not valid for arguments.")
20
+ }.should 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
  lambda {
25
25
  argument(:task, :string, "bar", true)
26
- }.must raise_error(ArgumentError, "An argument cannot be required and have default value.")
26
+ }.should raise_error(ArgumentError, "An argument cannot be required and have default value.")
27
27
  end
28
28
  end
29
29
 
30
30
  describe "#usage" do
31
31
  it "returns usage for string types" do
32
- argument(:foo, :string).usage.must == "FOO"
32
+ argument(:foo, :string).usage.should == "FOO"
33
33
  end
34
34
 
35
35
  it "returns usage for numeric types" do
36
- argument(:foo, :numeric).usage.must == "N"
36
+ argument(:foo, :numeric).usage.should == "N"
37
37
  end
38
38
 
39
39
  it "returns usage for array types" do
40
- argument(:foo, :array).usage.must == "one two three"
40
+ argument(:foo, :array).usage.should == "one two three"
41
41
  end
42
42
 
43
43
  it "returns usage for hash types" do
44
- argument(:foo, :hash).usage.must == "key:value"
44
+ argument(:foo, :hash).usage.should == "key:value"
45
45
  end
46
46
  end
47
47
  end
@@ -18,47 +18,47 @@ describe Thor::Arguments do
18
18
  describe "#parse" do
19
19
  it "parses arguments in the given order" do
20
20
  create :string => nil, :numeric => nil
21
- parse("name", "13")["string"].must == "name"
22
- parse("name", "13")["numeric"].must == 13
21
+ parse("name", "13")["string"].should == "name"
22
+ parse("name", "13")["numeric"].should == 13
23
23
  end
24
24
 
25
25
  it "accepts hashes" do
26
26
  create :string => nil, :hash => nil
27
- parse("product", "title:string", "age:integer")["string"].must == "product"
28
- parse("product", "title:string", "age:integer")["hash"].must == { "title" => "string", "age" => "integer"}
27
+ parse("product", "title:string", "age:integer")["string"].should == "product"
28
+ parse("product", "title:string", "age:integer")["hash"].should == { "title" => "string", "age" => "integer"}
29
29
  end
30
30
 
31
31
  it "accepts arrays" do
32
32
  create :string => nil, :array => nil
33
- parse("product", "title", "age")["string"].must == "product"
34
- parse("product", "title", "age")["array"].must == %w(title age)
33
+ parse("product", "title", "age")["string"].should == "product"
34
+ parse("product", "title", "age")["array"].should == %w(title age)
35
35
  end
36
36
 
37
37
  describe "with no inputs" do
38
38
  it "and no arguments returns an empty hash" do
39
39
  create
40
- parse.must == {}
40
+ parse.should == {}
41
41
  end
42
42
 
43
43
  it "and required arguments raises an error" do
44
44
  create :string => nil, :numeric => nil
45
- lambda { parse }.must raise_error(Thor::RequiredArgumentMissingError, "No value provided for required arguments 'string', 'numeric'")
45
+ lambda { parse }.should raise_error(Thor::RequiredArgumentMissingError, "No value provided for required arguments 'string', 'numeric'")
46
46
  end
47
47
 
48
48
  it "and default arguments returns default values" do
49
49
  create :string => "name", :numeric => 13
50
- parse.must == { "string" => "name", "numeric" => 13 }
50
+ parse.should == { "string" => "name", "numeric" => 13 }
51
51
  end
52
52
  end
53
53
 
54
54
  it "returns the input if it's already parsed" do
55
55
  create :string => nil, :hash => nil, :array => nil, :numeric => nil
56
- parse("", 0, {}, []).must == { "string" => "", "numeric" => 0, "hash" => {}, "array" => [] }
56
+ parse("", 0, {}, []).should == { "string" => "", "numeric" => 0, "hash" => {}, "array" => [] }
57
57
  end
58
58
 
59
59
  it "returns the default value if none is provided" do
60
60
  create :string => "foo", :numeric => 3.0
61
- parse("bar").must == { "string" => "bar", "numeric" => 3.0 }
61
+ parse("bar").should == { "string" => "bar", "numeric" => 3.0 }
62
62
  end
63
63
  end
64
64
  end
@@ -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.must == :string
19
- parse(:foo, :numeric).type.must == :numeric
18
+ parse(:foo, :string).type.should == :string
19
+ parse(:foo, :numeric).type.should == :numeric
20
20
  end
21
21
 
22
22
  it "has not default value" do
23
- parse(:foo, :string).default.must be_nil
24
- parse(:foo, :numeric).default.must be_nil
23
+ parse(:foo, :string).default.should be_nil
24
+ parse(:foo, :numeric).default.should 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.must == :string
30
+ parse(:foo, :required).type.should == :string
31
31
  end
32
32
 
33
33
  it "has no default value" do
34
- parse(:foo, :required).default.must be_nil
34
+ parse(:foo, :required).default.should 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.must == :string
40
+ parse(:foo, :bar).type.should == :string
41
41
  end
42
42
 
43
43
  it "has no default value" do
44
- parse(:foo, :bar).default.must be_nil
44
+ parse(:foo, :bar).default.should 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.must == :hash
51
+ parse(:foo, :a => :b).type.should == :hash
52
52
  end
53
53
 
54
54
  it "has default value equals to the hash" do
55
- parse(:foo, :a => :b).default.must == { :a => :b }
55
+ parse(:foo, :a => :b).default.should == { :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.must == :array
61
+ parse(:foo, [:a, :b]).type.should == :array
62
62
  end
63
63
 
64
64
  it "has default value equals to the array" do
65
- parse(:foo, [:a, :b]).default.must == [:a, :b]
65
+ parse(:foo, [:a, :b]).default.should == [: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.must == :string
71
+ parse(:foo, "bar").type.should == :string
72
72
  end
73
73
 
74
74
  it "has default value equals to the string" do
75
- parse(:foo, "bar").default.must == "bar"
75
+ parse(:foo, "bar").default.should == "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.must == :numeric
81
+ parse(:foo, 2.0).type.should == :numeric
82
82
  end
83
83
 
84
84
  it "has default value equals to the numeric" do
85
- parse(:foo, 2.0).default.must == 2.0
85
+ parse(:foo, 2.0).default.should == 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.must == :boolean
92
- parse(:foo, false).type.must == :boolean
91
+ parse(:foo, true).type.should == :boolean
92
+ parse(:foo, false).type.should == :boolean
93
93
  end
94
94
 
95
95
  it "has default value equals to the boolean" do
96
- parse(:foo, true).default.must == true
97
- parse(:foo, false).default.must == false
96
+ parse(:foo, true).default.should == true
97
+ parse(:foo, false).default.should == 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.must == "foo"
103
+ parse(:foo, true).name.should == "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.must == "foo"
109
+ parse([:foo, :bar, :baz], true).name.should == "foo"
110
110
  end
111
111
 
112
112
  it "sets all other items as aliases" do
113
- parse([:foo, :bar, :baz], true).aliases.must == [:bar, :baz]
113
+ parse([:foo, :bar, :baz], true).aliases.should == [: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.must == "--foo"
120
- option("--foo").switch_name.must == "--foo"
119
+ option("foo").switch_name.should == "--foo"
120
+ option("--foo").switch_name.should == "--foo"
121
121
  end
122
122
 
123
123
  it "returns the human name" do
124
- option("foo").human_name.must == "foo"
125
- option("--foo").human_name.must == "foo"
124
+ option("foo").human_name.should == "foo"
125
+ option("--foo").human_name.should == "foo"
126
126
  end
127
127
 
128
128
  it "converts underscores to dashes" do
129
- option("foo_bar").switch_name.must == "--foo-bar"
129
+ option("foo_bar").switch_name.should == "--foo-bar"
130
130
  end
131
131
 
132
132
  it "can be required and have default values" do
133
133
  option = option("foo", nil, true, :string, "bar")
134
- option.default.must == "bar"
135
- option.must be_required
134
+ option.default.should == "bar"
135
+ option.should be_required
136
136
  end
137
137
 
138
138
  it "cannot be required and have type boolean" do
139
139
  lambda {
140
140
  option("foo", nil, true, :boolean)
141
- }.must raise_error(ArgumentError, "An option cannot be boolean and required.")
141
+ }.should 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).must be_string
146
- parse(:foo, :boolean).must be_boolean
147
- parse(:foo, :numeric).must be_numeric
145
+ parse(:foo, :string).should be_string
146
+ parse(:foo, :boolean).should be_boolean
147
+ parse(:foo, :numeric).should be_numeric
148
148
  end
149
149
 
150
150
  it "raises an error on method missing" do
151
151
  lambda {
152
152
  parse(:foo, :string).unknown?
153
- }.must raise_error(NoMethodError)
153
+ }.should 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.must == "[--foo=FOO]"
159
+ parse(:foo, :string).usage.should == "[--foo=FOO]"
160
160
  end
161
161
 
162
162
  it "returns usage for numeric types" do
163
- parse(:foo, :numeric).usage.must == "[--foo=N]"
163
+ parse(:foo, :numeric).usage.should == "[--foo=N]"
164
164
  end
165
165
 
166
166
  it "returns usage for array types" do
167
- parse(:foo, :array).usage.must == "[--foo=one two three]"
167
+ parse(:foo, :array).usage.should == "[--foo=one two three]"
168
168
  end
169
169
 
170
170
  it "returns usage for hash types" do
171
- parse(:foo, :hash).usage.must == "[--foo=key:value]"
171
+ parse(:foo, :hash).usage.should == "[--foo=key:value]"
172
172
  end
173
173
 
174
174
  it "returns usage for boolean types" do
175
- parse(:foo, :boolean).usage.must == "[--foo]"
175
+ parse(:foo, :boolean).usage.should == "[--foo]"
176
176
  end
177
177
 
178
178
  it "uses padding when no aliases is given" do
179
- parse(:foo, :boolean).usage(4).must == " [--foo]"
179
+ parse(:foo, :boolean).usage(4).should == " [--foo]"
180
180
  end
181
181
 
182
182
  it "uses banner when supplied" do
183
- option(:foo, nil, false, :string, nil, "BAR").usage.must == "[--foo=BAR]"
183
+ option(:foo, nil, false, :string, nil, "BAR").usage.should == "[--foo=BAR]"
184
184
  end
185
185
 
186
186
  it "checkes when banner is an empty string" do
187
- option(:foo, nil, false, :string, nil, "").usage.must == "[--foo]"
187
+ option(:foo, nil, false, :string, nil, "").usage.should == "[--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.must == "--foo=FOO"
192
+ parse(:foo, :required).usage.should == "--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.must == "-f, -b, --foo=FOO"
198
+ parse([:foo, "-f", "-b"], :required).usage.should == "-f, -b, --foo=FOO"
199
199
  end
200
200
  end
201
201
  end