cli 1.3.1 → 1.4.0

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