cli 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -7
  3. data/Gemfile.lock +29 -37
  4. data/README.md +43 -44
  5. data/Rakefile +1 -28
  6. data/cli.gemspec +14 -84
  7. data/examples/httpclient +6 -6
  8. data/examples/ls +4 -4
  9. data/examples/processor +5 -5
  10. data/examples/sinatra +9 -9
  11. data/lib/cli/dsl.rb +3 -3
  12. data/rdoc/CLI/Arguments.html +178 -0
  13. data/rdoc/CLI/DSL/Argument.html +200 -0
  14. data/rdoc/CLI/DSL/Arguments.html +172 -0
  15. data/rdoc/CLI/DSL/Base.html +154 -0
  16. data/rdoc/CLI/DSL/Cast.html +152 -0
  17. data/rdoc/CLI/DSL/Description.html +150 -0
  18. data/rdoc/CLI/DSL/Input.html +143 -0
  19. data/rdoc/CLI/DSL/MultiDefault.html +151 -0
  20. data/rdoc/CLI/DSL/Option.html +143 -0
  21. data/rdoc/CLI/DSL/Options.html +142 -0
  22. data/rdoc/CLI/DSL/Switch.html +267 -0
  23. data/rdoc/CLI/DSL/Value.html +238 -0
  24. data/rdoc/CLI/DSL.html +91 -0
  25. data/rdoc/CLI/Options.html +200 -0
  26. data/rdoc/CLI/ParserError/ArgumentNameSpecifiedTwice.html +138 -0
  27. data/rdoc/CLI/ParserError/LongNameSpecifiedTwiceError.html +138 -0
  28. data/rdoc/CLI/ParserError/MultipleArgumentsSpecifierError.html +138 -0
  29. data/rdoc/CLI/ParserError/NameArgumetNotSymbolError.html +138 -0
  30. data/rdoc/CLI/ParserError/OptionsArgumentNotHashError.html +138 -0
  31. data/rdoc/CLI/ParserError/ShortNameIsInvalidError.html +138 -0
  32. data/rdoc/CLI/ParserError/ShortNameNotSymbolError.html +138 -0
  33. data/rdoc/CLI/ParserError/ShortNameSpecifiedTwiceError.html +138 -0
  34. data/rdoc/CLI/ParserError.html +97 -0
  35. data/rdoc/CLI/ParsingError/CastError.html +138 -0
  36. data/rdoc/CLI/ParsingError/MandatoryArgumentNotSpecifiedError.html +138 -0
  37. data/rdoc/CLI/ParsingError/MandatoryOptionsNotSpecifiedError.html +138 -0
  38. data/rdoc/CLI/ParsingError/MissingOptionValueError.html +138 -0
  39. data/rdoc/CLI/ParsingError/UnknownSwitchError.html +138 -0
  40. data/rdoc/CLI/ParsingError/UsageError.html +97 -0
  41. data/rdoc/CLI/ParsingError.html +97 -0
  42. data/rdoc/CLI/Switches.html +306 -0
  43. data/rdoc/CLI/Values.html +202 -0
  44. data/rdoc/CLI.html +652 -0
  45. data/rdoc/README_md.html +553 -0
  46. data/rdoc/created.rid +7 -0
  47. data/rdoc/css/fonts.css +167 -0
  48. data/rdoc/css/rdoc.css +639 -0
  49. data/rdoc/fonts/Lato-Light.ttf +0 -0
  50. data/rdoc/fonts/Lato-LightItalic.ttf +0 -0
  51. data/rdoc/fonts/Lato-Regular.ttf +0 -0
  52. data/rdoc/fonts/Lato-RegularItalic.ttf +0 -0
  53. data/rdoc/fonts/SourceCodePro-Bold.ttf +0 -0
  54. data/rdoc/fonts/SourceCodePro-Regular.ttf +0 -0
  55. data/rdoc/images/add.png +0 -0
  56. data/rdoc/images/arrow_up.png +0 -0
  57. data/rdoc/images/brick.png +0 -0
  58. data/rdoc/images/brick_link.png +0 -0
  59. data/rdoc/images/bug.png +0 -0
  60. data/rdoc/images/bullet_black.png +0 -0
  61. data/rdoc/images/bullet_toggle_minus.png +0 -0
  62. data/rdoc/images/bullet_toggle_plus.png +0 -0
  63. data/rdoc/images/date.png +0 -0
  64. data/rdoc/images/delete.png +0 -0
  65. data/rdoc/images/find.png +0 -0
  66. data/rdoc/images/loadingAnimation.gif +0 -0
  67. data/rdoc/images/macFFBgHack.png +0 -0
  68. data/rdoc/images/package.png +0 -0
  69. data/rdoc/images/page_green.png +0 -0
  70. data/rdoc/images/page_white_text.png +0 -0
  71. data/rdoc/images/page_white_width.png +0 -0
  72. data/rdoc/images/plugin.png +0 -0
  73. data/rdoc/images/ruby.png +0 -0
  74. data/rdoc/images/tag_blue.png +0 -0
  75. data/rdoc/images/tag_green.png +0 -0
  76. data/rdoc/images/transparent.png +0 -0
  77. data/rdoc/images/wrench.png +0 -0
  78. data/rdoc/images/wrench_orange.png +0 -0
  79. data/rdoc/images/zoom.png +0 -0
  80. data/rdoc/index.html +120 -0
  81. data/rdoc/js/darkfish.js +84 -0
  82. data/rdoc/js/navigation.js +105 -0
  83. data/rdoc/js/navigation.js.gz +0 -0
  84. data/rdoc/js/search.js +110 -0
  85. data/rdoc/js/search_index.js +1 -0
  86. data/rdoc/js/search_index.js.gz +0 -0
  87. data/rdoc/js/searcher.js +229 -0
  88. data/rdoc/js/searcher.js.gz +0 -0
  89. data/rdoc/table_of_contents.html +533 -0
  90. data/spec/argument_spec.rb +122 -99
  91. data/spec/cli_spec.rb +27 -28
  92. data/spec/conflict_reporting_spec.rb +16 -17
  93. data/spec/option_spec.rb +79 -56
  94. data/spec/separator_spec.rb +19 -20
  95. data/spec/stdin_spec.rb +13 -14
  96. data/spec/switch_spec.rb +15 -16
  97. data/spec/usage_spec.rb +80 -81
  98. metadata +91 -104
  99. data/.document +0 -5
  100. data/.rspec +0 -1
  101. data/VERSION +0 -1
  102. data/features/cli.feature +0 -9
  103. data/features/step_definitions/cli_steps.rb +0 -0
  104. data/features/support/env.rb +0 -13
@@ -6,73 +6,97 @@ describe CLI do
6
6
  ps = CLI.new do
7
7
  argument :log
8
8
  end.parse(['/tmp'])
9
- ps.log.should be_a String
10
- ps.log.should == '/tmp'
9
+ expect(ps.log).to be_a String
10
+ expect(ps.log).to eq '/tmp'
11
11
  end
12
12
 
13
13
  it "should cast mandatory argument" do
14
14
  ps = CLI.new do
15
15
  argument :log, :cast => Pathname
16
16
  end.parse(['/tmp'])
17
- ps.log.should be_a Pathname
18
- ps.log.to_s.should == '/tmp'
17
+ expect(ps.log).to be_a Pathname
18
+ expect(ps.log.to_s).to eq '/tmp'
19
19
  end
20
20
 
21
21
  it "should cast mandatory argument to numerical class" do
22
22
  ps = CLI.new do
23
23
  argument :number, :cast => Integer
24
24
  end.parse(['123'])
25
- ps.number.should be_a Integer
26
- ps.number.should == 123
25
+ expect(ps.number).to be_a Integer
26
+ expect(ps.number).to eq 123
27
27
 
28
28
  ps = CLI.new do
29
29
  argument :number, :cast => Float
30
30
  end.parse(['123'])
31
- ps.number.should be_a Float
32
- ps.number.should == 123.0
31
+ expect(ps.number).to be_a Float
32
+ expect(ps.number).to eq 123.0
33
+ end
34
+
35
+ it "casting should fail if not proper integer given" do
36
+ expect {
37
+ ps = CLI.new do
38
+ argument :size, :cast => Integer
39
+ end.parse(['24.99'])
40
+ }.to raise_error(CLI::ParsingError::CastError)
41
+ end
42
+
43
+ it "casting should fail if not proper float given" do
44
+ expect {
45
+ ps = CLI.new do
46
+ argument :size, :cast => Float
47
+ end.parse(['24.99x'])
48
+ }.to raise_error(CLI::ParsingError::CastError)
49
+ end
50
+
51
+ it "casting should fail if there is error in cast lambda" do
52
+ expect {
53
+ ps = CLI.new do
54
+ argument :size, :cast => lambda{|v| fail 'test'}
55
+ end.parse(['24.99x'])
56
+ }.to raise_error(CLI::ParsingError::CastError)
33
57
  end
34
58
 
35
59
  it "should cast default value" do
36
60
  ps = CLI.new do
37
61
  argument :number, :cast => Integer, :default => '123'
38
62
  end.parse([])
39
- ps.number.should be_a Integer
40
- ps.number.should == 123
63
+ expect(ps.number).to be_a Integer
64
+ expect(ps.number).to eq 123
41
65
  end
42
66
 
43
67
  it "should cast value of multiple arguments argument" do
44
68
  ps = CLI.new do
45
69
  arguments :numbers, :cast => Integer
46
70
  end.parse(['1', '2', '3'])
47
- ps.numbers.should be_a Array
48
- ps.numbers[0].should be_a Integer
49
- ps.numbers[0].should == 1
50
- ps.numbers[1].should be_a Integer
51
- ps.numbers[1].should == 2
52
- ps.numbers[2].should be_a Integer
53
- ps.numbers[2].should == 3
71
+ expect(ps.numbers).to be_a Array
72
+ expect(ps.numbers[0]).to be_a Integer
73
+ expect(ps.numbers[0]).to eq 1
74
+ expect(ps.numbers[1]).to be_a Integer
75
+ expect(ps.numbers[1]).to eq 2
76
+ expect(ps.numbers[2]).to be_a Integer
77
+ expect(ps.numbers[2]).to eq 3
54
78
  end
55
79
 
56
80
  it "should cast single default value of multiple arguments argument" do
57
81
  ps = CLI.new do
58
82
  arguments :numbers, :cast => Integer, :default => '1'
59
83
  end.parse([])
60
- ps.numbers.should be_a Array
61
- ps.numbers[0].should be_a Integer
62
- ps.numbers[0].should == 1
84
+ expect(ps.numbers).to be_a Array
85
+ expect(ps.numbers[0]).to be_a Integer
86
+ expect(ps.numbers[0]).to eq 1
63
87
  end
64
88
 
65
89
  it "should cast default value array of multiple arguments argument" do
66
90
  ps = CLI.new do
67
91
  arguments :numbers, :cast => Integer, :default => ['1', '2', '3']
68
92
  end.parse([])
69
- ps.numbers.should be_a Array
70
- ps.numbers[0].should be_a Integer
71
- ps.numbers[0].should == 1
72
- ps.numbers[1].should be_a Integer
73
- ps.numbers[1].should == 2
74
- ps.numbers[2].should be_a Integer
75
- ps.numbers[2].should == 3
93
+ expect(ps.numbers).to be_a Array
94
+ expect(ps.numbers[0]).to be_a Integer
95
+ expect(ps.numbers[0]).to eq 1
96
+ expect(ps.numbers[1]).to be_a Integer
97
+ expect(ps.numbers[1]).to eq 2
98
+ expect(ps.numbers[2]).to be_a Integer
99
+ expect(ps.numbers[2]).to eq 3
76
100
  end
77
101
 
78
102
  it "should handle multiple arguments" do
@@ -80,10 +104,10 @@ describe CLI do
80
104
  argument :log, :cast => Pathname
81
105
  argument :test
82
106
  end.parse(['/tmp', 'hello'])
83
- ps.log.should be_a Pathname
84
- ps.log.to_s.should == '/tmp'
85
- ps.test.should be_a String
86
- ps.test.should == 'hello'
107
+ expect(ps.log).to be_a Pathname
108
+ expect(ps.log.to_s).to eq '/tmp'
109
+ expect(ps.test).to be_a String
110
+ expect(ps.test).to eq 'hello'
87
111
  end
88
112
 
89
113
  it "should handle multi arguments" do
@@ -91,63 +115,63 @@ describe CLI do
91
115
  argument :log, :cast => Pathname
92
116
  arguments :words
93
117
  end.parse(['/tmp', 'hello', 'world', 'test'])
94
- ps.log.should be_a Pathname
95
- ps.log.to_s.should == '/tmp'
118
+ expect(ps.log).to be_a Pathname
119
+ expect(ps.log.to_s).to eq '/tmp'
96
120
 
97
- ps.words.should be_a Array
98
- ps.words[0].should == 'hello'
99
- ps.words[1].should == 'world'
100
- ps.words[2].should == 'test'
121
+ expect(ps.words).to be_a Array
122
+ expect(ps.words[0]).to eq 'hello'
123
+ expect(ps.words[1]).to eq 'world'
124
+ expect(ps.words[2]).to eq 'test'
101
125
  end
102
126
 
103
127
  it "should raise error if not symbol and optional hash is passed" do
104
- lambda {
128
+ expect {
105
129
  ps = CLI.new do
106
130
  argument 'number'
107
131
  end
108
- }.should raise_error CLI::ParserError::NameArgumetNotSymbolError, "argument name has to be of type Symbol, got String"
132
+ }.to raise_error CLI::ParserError::NameArgumetNotSymbolError, "argument name has to be of type Symbol, got String"
109
133
 
110
- lambda {
134
+ expect {
111
135
  ps = CLI.new do
112
136
  argument :number, :test
113
137
  end
114
- }.should raise_error CLI::ParserError::OptionsArgumentNotHashError, "argument options has to be of type Hash, got Symbol"
138
+ }.to raise_error CLI::ParserError::OptionsArgumentNotHashError, "argument options has to be of type Hash, got Symbol"
115
139
  end
116
140
 
117
141
  it "should raise error if artument name is specified twice" do
118
- lambda {
142
+ expect {
119
143
  ps = CLI.new do
120
144
  argument :number
121
145
  argument :number
122
146
  end
123
- }.should raise_error CLI::ParserError::ArgumentNameSpecifiedTwice, "argument 'number' specified twice"
147
+ }.to raise_error CLI::ParserError::ArgumentNameSpecifiedTwice, "argument 'number' specified twice"
124
148
  end
125
149
 
126
150
  it "should be required by default and raise error if not given" do
127
- lambda {
151
+ expect {
128
152
  ps = CLI.new do
129
153
  argument :log
130
154
  end.parse([])
131
- }.should raise_error CLI::ParsingError::MandatoryArgumentNotSpecifiedError, "mandatory argument 'log' not given"
155
+ }.to raise_error CLI::ParsingError::MandatoryArgumentNotSpecifiedError, "mandatory argument 'log' not given"
132
156
  end
133
157
 
134
158
  it "should raise error if casting fail" do
135
159
  require 'ip'
136
- lambda {
160
+ expect {
137
161
  ps = CLI.new do
138
162
  argument :log, :cast => IP
139
163
  end.parse(['abc'])
140
- }.should raise_error CLI::ParsingError::CastError, "failed to cast: 'log' to type: IP: invalid address"
164
+ }.to raise_error CLI::ParsingError::CastError, "failed to cast: 'log' to type: IP: invalid address"
141
165
  end
142
166
 
143
167
  it "should raise error if multiple artuments argument defined twice" do
144
- lambda {
168
+ expect {
145
169
  ps = CLI.new do
146
170
  arguments :test1
147
171
  argument :test2
148
172
  arguments :test3
149
173
  end
150
- }.should raise_error CLI::ParserError::MultipleArgumentsSpecifierError, "only one 'arguments' specifier can be used, got: test1, test3"
174
+ }.to raise_error CLI::ParserError::MultipleArgumentsSpecifierError, "only one 'arguments' specifier can be used, got: test1, test3"
151
175
  end
152
176
 
153
177
  describe "with defaults" do
@@ -159,11 +183,11 @@ describe CLI do
159
183
  argument :test4, :default => 'd'
160
184
  argument :test5, :default => 'e'
161
185
  end.parse(['a', 'b'])
162
- ps.test1.should == 'a'
163
- ps.test2.should == 'b'
164
- ps.test3.should == 'c'
165
- ps.test4.should == 'd'
166
- ps.test5.should == 'e'
186
+ expect(ps.test1).to eq 'a'
187
+ expect(ps.test2).to eq 'b'
188
+ expect(ps.test3).to eq 'c'
189
+ expect(ps.test4).to eq 'd'
190
+ expect(ps.test5).to eq 'e'
167
191
 
168
192
  ps = CLI.new do
169
193
  argument :log, :cast => Pathname
@@ -171,10 +195,10 @@ describe CLI do
171
195
  argument :test
172
196
  argument :code, :cast => Integer, :default => '123'
173
197
  end.parse(['/tmp', 'hello', 'world'])
174
- ps.log.to_s.should == '/tmp'
175
- ps.magick.should == 'hello'
176
- ps.test.should == 'world'
177
- ps.code.should == 123
198
+ expect(ps.log.to_s).to eq '/tmp'
199
+ expect(ps.magick).to eq 'hello'
200
+ expect(ps.test).to eq 'world'
201
+ expect(ps.code).to eq 123
178
202
  end
179
203
 
180
204
  it "should fill multiple argumets argument with remaining arguments after filling mandatory and default arguments" do
@@ -187,12 +211,12 @@ describe CLI do
187
211
  argument :code, :cast => Integer, :default => '123'
188
212
  end.parse(['/tmp', 'number', 'test', 'hello', 'world', 'abc', 'test2', '42'])
189
213
 
190
- ps.log.to_s.should == '/tmp'
191
- ps.magick.should == 'number'
192
- ps.test.should == 'test'
193
- ps.words.should == ['hello', 'world', 'abc']
194
- ps.test2.should == 'test2'
195
- ps.code.should == 42
214
+ expect(ps.log.to_s).to eq '/tmp'
215
+ expect(ps.magick).to eq 'number'
216
+ expect(ps.test).to eq 'test'
217
+ expect(ps.words).to eq ['hello', 'world', 'abc']
218
+ expect(ps.test2).to eq 'test2'
219
+ expect(ps.code).to eq 42
196
220
  end
197
221
 
198
222
  it "should use default single value for multiple arguments argument when not enought arguments given" do
@@ -205,12 +229,12 @@ describe CLI do
205
229
  argument :code, :cast => Integer, :default => '123'
206
230
  end.parse(['/tmp', 'test', 'test2'])
207
231
 
208
- ps.log.to_s.should == '/tmp'
209
- ps.magick.should == 'word'
210
- ps.test.should == 'test'
211
- ps.words.should == ['hello']
212
- ps.test2.should == 'test2'
213
- ps.code.should == 123
232
+ expect(ps.log.to_s).to eq '/tmp'
233
+ expect(ps.magick).to eq 'word'
234
+ expect(ps.test).to eq 'test'
235
+ expect(ps.words).to eq ['hello']
236
+ expect(ps.test2).to eq 'test2'
237
+ expect(ps.code).to eq 123
214
238
  end
215
239
 
216
240
  it "should use default array of values for multiple arguments argument when not enought arguments given" do
@@ -223,12 +247,12 @@ describe CLI do
223
247
  argument :code, :cast => Integer, :default => '123'
224
248
  end.parse(['/tmp', 'test', 'test2'])
225
249
 
226
- ps.log.to_s.should == '/tmp'
227
- ps.magick.should == 'word'
228
- ps.test.should == 'test'
229
- ps.words.should == ['hello', 'world', 'abc']
230
- ps.test2.should == 'test2'
231
- ps.code.should == 123
250
+ expect(ps.log.to_s).to eq '/tmp'
251
+ expect(ps.magick).to eq 'word'
252
+ expect(ps.test).to eq 'test'
253
+ expect(ps.words).to eq ['hello', 'world', 'abc']
254
+ expect(ps.test2).to eq 'test2'
255
+ expect(ps.code).to eq 123
232
256
  end
233
257
 
234
258
  it "should fill at least one value of required multiple arguments argument" do
@@ -239,11 +263,11 @@ describe CLI do
239
263
  argument :test4, :default => 'd'
240
264
  argument :test5, :default => 'e'
241
265
  end.parse(['a', 'c'])
242
- ps.test1.should == 'a'
243
- ps.test2.should == 'b'
244
- ps.test3.should == ['c']
245
- ps.test4.should == 'd'
246
- ps.test5.should == 'e'
266
+ expect(ps.test1).to eq 'a'
267
+ expect(ps.test2).to eq 'b'
268
+ expect(ps.test3).to eq ['c']
269
+ expect(ps.test4).to eq 'd'
270
+ expect(ps.test5).to eq 'e'
247
271
  end
248
272
  end
249
273
 
@@ -256,19 +280,19 @@ describe CLI do
256
280
  argument :test4, :required => false
257
281
  argument :test5, :required => false
258
282
  end.parse(['a', 'b'])
259
- ps.test1.should == 'a'
260
- ps.test2.should == 'b'
261
- ps.test3.should be_nil
262
- ps.test4.should be_nil
263
- ps.test5.should be_nil
283
+ expect(ps.test1).to eq 'a'
284
+ expect(ps.test2).to eq 'b'
285
+ expect(ps.test3).to be_nil
286
+ expect(ps.test4).to be_nil
287
+ expect(ps.test5).to be_nil
264
288
 
265
289
  ps = CLI.new do
266
290
  argument :log, :cast => Pathname
267
291
  argument :test, :required => false
268
292
  end.parse(['/tmp'])
269
- ps.log.should be_a Pathname
270
- ps.log.to_s.should == '/tmp'
271
- ps.test.should be_nil
293
+ expect(ps.log).to be_a Pathname
294
+ expect(ps.log.to_s).to eq '/tmp'
295
+ expect(ps.test).to be_nil
272
296
  end
273
297
 
274
298
  it "should use empty array for multiple arguments argument when not enought arguments given and it is not required" do
@@ -277,9 +301,9 @@ describe CLI do
277
301
  argument :test2, :required => false
278
302
  arguments :test3, :required => false
279
303
  end.parse(['a', 'b'])
280
- ps.test1.should == 'a'
281
- ps.test2.should == 'b'
282
- ps.test3.should == []
304
+ expect(ps.test1).to eq 'a'
305
+ expect(ps.test2).to eq 'b'
306
+ expect(ps.test3).to eq []
283
307
 
284
308
  ps = CLI.new do
285
309
  argument :log, :cast => Pathname
@@ -290,14 +314,13 @@ describe CLI do
290
314
  argument :code, :cast => Integer, :default => '123'
291
315
  end.parse(['/tmp', 'test', 'test2'])
292
316
 
293
- ps.log.to_s.should == '/tmp'
294
- ps.magick.should == 'word'
295
- ps.test.should == 'test'
296
- ps.words.should == []
297
- ps.test2.should == 'test2'
298
- ps.code.should == 123
317
+ expect(ps.log.to_s).to eq '/tmp'
318
+ expect(ps.magick).to eq 'word'
319
+ expect(ps.test).to eq 'test'
320
+ expect(ps.words).to eq []
321
+ expect(ps.test2).to eq 'test2'
322
+ expect(ps.code).to eq 123
299
323
  end
300
324
  end
301
325
  end
302
326
  end
303
-
data/spec/cli_spec.rb CHANGED
@@ -16,20 +16,20 @@ describe CLI do
16
16
  argument :code, :cast => Integer, :default => '123'
17
17
  end.parse(['-l', 'singapore', '--power-up', 'yes', '-s', '24', '--debug', '--size', 'XXXL', '/tmp', 'hello'])
18
18
 
19
- ps.group.should == 'red'
20
- ps.power_up.should == 'yes'
21
- ps.speed.should == 24
22
- ps.size.should == 'XXXL'
19
+ expect(ps.group).to eq 'red'
20
+ expect(ps.power_up).to eq 'yes'
21
+ expect(ps.speed).to eq 24
22
+ expect(ps.size).to eq 'XXXL'
23
23
 
24
- ps.log.to_s.should == '/tmp'
25
- ps.magick.should == 'word'
26
- ps.test.should == 'hello'
27
- ps.code.should == 123
28
- ps.debug.should be_true
24
+ expect(ps.log.to_s).to eq '/tmp'
25
+ expect(ps.magick).to eq 'word'
26
+ expect(ps.test).to eq 'hello'
27
+ expect(ps.code).to eq 123
28
+ expect(ps.debug).to be true
29
29
  end
30
30
 
31
31
  it "provides name method that provides current program name" do
32
- CLI.name.should == 'rspec'
32
+ expect(CLI.name).to eq 'rspec'
33
33
  end
34
34
 
35
35
  describe "parse!" do
@@ -40,9 +40,9 @@ describe CLI do
40
40
  argument :code
41
41
  end.parse!(['-l', 'singapore', '--debug', 'hello'])
42
42
 
43
- ps.location.should == 'singapore'
44
- ps.debug.should be_true
45
- ps.code.should == 'hello'
43
+ expect(ps.location).to eq 'singapore'
44
+ expect(ps.debug).to be true
45
+ expect(ps.code).to eq 'hello'
46
46
  end
47
47
 
48
48
  it "should return value structure where all values are set" do
@@ -51,15 +51,15 @@ describe CLI do
51
51
  switch :debug
52
52
  end.parse!([]).marshal_dump
53
53
 
54
- h.member?(:location).should be_true
55
- h[:location].should be_nil
54
+ expect(h.member?(:location)).to be true
55
+ expect(h[:location]).to be_nil
56
56
 
57
- h.member?(:debug).should be_true
58
- h[:debug].should be_nil
57
+ expect(h.member?(:debug)).to be true
58
+ expect(h[:debug]).to be_nil
59
59
  end
60
60
 
61
61
  it "should take a block that can be used to verify passed values" do
62
- lambda {
62
+ expect {
63
63
  ps = CLI.new do
64
64
  option :location, :short => :l
65
65
  switch :debug
@@ -68,10 +68,10 @@ describe CLI do
68
68
  end.parse!(['-l', 'singapore', '--debug', 'hello']) do |values|
69
69
  fail '--debug can not be used with --verbose' if values.debug and values.verbose
70
70
  end
71
- }.should_not raise_error
71
+ }.not_to raise_error
72
72
 
73
73
  out = stderr_read do
74
- lambda {
74
+ expect {
75
75
  ps = CLI.new do
76
76
  option :location, :short => :l
77
77
  switch :debug
@@ -80,23 +80,22 @@ describe CLI do
80
80
  end.parse!(['-l', 'singapore', '--debug', '--verbose', 'hello']) do |values|
81
81
  fail '--debug can not be used with --verbose' if values.debug and values.verbose
82
82
  end
83
- }.should raise_error SystemExit
83
+ }.to raise_error SystemExit
84
84
  end
85
- out.should include('Error: --debug can not be used with --verbose')
86
- out.should include('Usage:')
85
+ expect(out).to include('Error: --debug can not be used with --verbose')
86
+ expect(out).to include('Usage:')
87
87
  end
88
88
 
89
89
  it "should exit displaying usage and error message on standard error on usage error" do
90
90
  out = stderr_read do
91
- lambda {
91
+ expect {
92
92
  ps = CLI.new do
93
93
  option :weight, :required => true
94
94
  end.parse!([])
95
- }.should raise_error SystemExit
95
+ }.to raise_error SystemExit
96
96
  end
97
- out.should include('Error: mandatory options not specified: --weight')
98
- out.should include('Usage:')
97
+ expect(out).to include('Error: mandatory options not specified: --weight')
98
+ expect(out).to include('Usage:')
99
99
  end
100
100
  end
101
101
  end
102
-
@@ -4,66 +4,65 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
  describe CLI do
5
5
  describe "name conflict reporting" do
6
6
  it "raise error when long names configlict" do
7
- lambda {
7
+ expect {
8
8
  ps = CLI.new do
9
9
  switch :location
10
10
  switch :location
11
11
  end
12
- }.should raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'switch --location specified twice'
12
+ }.to raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'switch --location specified twice'
13
13
 
14
- lambda {
14
+ expect {
15
15
  ps = CLI.new do
16
16
  option :location
17
17
  option :location
18
18
  end
19
- }.should raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'option --location specified twice'
19
+ }.to raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'option --location specified twice'
20
20
 
21
- lambda {
21
+ expect {
22
22
  ps = CLI.new do
23
23
  switch :location
24
24
  option :location
25
25
  end
26
- }.should raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'switch and option --location specified twice'
26
+ }.to raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'switch and option --location specified twice'
27
27
 
28
- lambda {
28
+ expect {
29
29
  ps = CLI.new do
30
30
  option :location
31
31
  switch :location
32
32
  end
33
- }.should raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'option and switch --location specified twice'
33
+ }.to raise_error CLI::ParserError::LongNameSpecifiedTwiceError, 'option and switch --location specified twice'
34
34
  end
35
35
  end
36
36
 
37
37
  describe "short name conflict reporting" do
38
38
  it "raise error when short names configlict" do
39
- lambda {
39
+ expect {
40
40
  ps = CLI.new do
41
41
  switch :location, :short => :l
42
42
  switch :location2, :short => :l
43
43
  end
44
- }.should raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short switch -l specified twice'
44
+ }.to raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short switch -l specified twice'
45
45
 
46
- lambda {
46
+ expect {
47
47
  ps = CLI.new do
48
48
  option :location, :short => :l
49
49
  option :location2, :short => :l
50
50
  end
51
- }.should raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short option -l specified twice'
51
+ }.to raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short option -l specified twice'
52
52
 
53
- lambda {
53
+ expect {
54
54
  ps = CLI.new do
55
55
  switch :location, :short => :l
56
56
  option :location2, :short => :l
57
57
  end
58
- }.should raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short switch and option -l specified twice'
58
+ }.to raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short switch and option -l specified twice'
59
59
 
60
- lambda {
60
+ expect {
61
61
  ps = CLI.new do
62
62
  option :location2, :short => :l
63
63
  switch :location, :short => :l
64
64
  end
65
- }.should raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short option and switch -l specified twice'
65
+ }.to raise_error CLI::ParserError::ShortNameSpecifiedTwiceError, 'short option and switch -l specified twice'
66
66
  end
67
67
  end
68
68
  end
69
-