mspec 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,115 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'mspec/helpers/ruby_exe'
3
+ require 'rbconfig'
4
+
5
+ class RubyExeSpecs
6
+ end
7
+
8
+ describe "#ruby_exe_options" do
9
+ before :all do
10
+ @verbose = $VERBOSE
11
+ $VERBOSE = nil
12
+
13
+ @ruby_name = Object.const_get :RUBY_NAME
14
+ @ruby_exe_env = ENV['RUBY_EXE']
15
+
16
+ @script = RubyExeSpecs.new
17
+ end
18
+
19
+ after :all do
20
+ Object.const_set :RUBY_NAME, @ruby_name
21
+ ENV['RUBY_EXE'] = @ruby_exe_env
22
+ $VERBOSE = @verbose
23
+ end
24
+
25
+ before :each do
26
+ @script = RubyExeSpecs.new
27
+ end
28
+
29
+ it "returns ENV['RUBY_EXE'] when passed :env" do
30
+ ENV['RUBY_EXE'] = "kowabunga"
31
+ @script.ruby_exe_options(:env).should == "kowabunga"
32
+ end
33
+
34
+ it "returns 'bin/rbx' when passed :engine and RUBY_NAME is 'rbx'" do
35
+ Object.const_set :RUBY_NAME, 'rbx'
36
+ @script.ruby_exe_options(:engine).should == 'bin/rbx'
37
+ end
38
+
39
+ it "returns 'bin/jruby' when passed :engine and RUBY_NAME is 'jruby'" do
40
+ Object.const_set :RUBY_NAME, 'jruby'
41
+ @script.ruby_exe_options(:engine).should == 'bin/jruby'
42
+ end
43
+
44
+ it "returns 'ir' when passed :engine and RUBY_NAME is 'ironruby'" do
45
+ Object.const_set :RUBY_NAME, 'ironruby'
46
+ @script.ruby_exe_options(:engine).should == 'ir'
47
+ end
48
+
49
+ it "returns RUBY_NAME + $(EXEEXT) when passed :name" do
50
+ bin = RUBY_NAME + (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
51
+ name = File.join ".", bin
52
+ @script.ruby_exe_options(:name).should == name
53
+ end
54
+
55
+ it "returns $(bindir)/$(RUBY_INSTALL_NAME) + $(EXEEXT) when passed :install_name" do
56
+ bin = Config::CONFIG['RUBY_INSTALL_NAME'] + (Config::CONFIG['EXEEXT'] || Config::CONFIG['exeext'] || '')
57
+ name = File.join Config::CONFIG['bindir'], bin
58
+ @script.ruby_exe_options(:install_name).should == name
59
+ end
60
+ end
61
+
62
+ describe "#resolve_ruby_exe" do
63
+ before :all do
64
+ @script = RubyExeSpecs.new
65
+ end
66
+
67
+ it "returns the value returned by #ruby_exe_options if it exists and is executable" do
68
+ name = "ruby_spec_exe"
69
+ @script.should_receive(:ruby_exe_options).and_return(name)
70
+ File.should_receive(:exists?).with(name).and_return(true)
71
+ File.should_receive(:executable?).with(name).and_return(true)
72
+ @script.resolve_ruby_exe.should == name
73
+ end
74
+
75
+ it "returns nil if no exe is found" do
76
+ File.should_receive(:exists?).at_least(:once).and_return(false)
77
+ @script.resolve_ruby_exe.should be_nil
78
+ end
79
+ end
80
+
81
+ describe Object, "#ruby_exe" do
82
+ before :all do
83
+ @verbose = $VERBOSE
84
+ $VERBOSE = nil
85
+
86
+ @ruby_flags = ENV["RUBY_FLAGS"]
87
+ ENV["RUBY_FLAGS"] = "-w -Q"
88
+
89
+ @ruby_exe = Object.const_get :RUBY_EXE
90
+ Object.const_set :RUBY_EXE, 'ruby_spec_exe'
91
+
92
+ @script = RubyExeSpecs.new
93
+ end
94
+
95
+ after :all do
96
+ Object.const_set :RUBY_EXE, @ruby_exe
97
+ ENV["RUBY_FLAGS"] = @ruby_flags
98
+ $VERBOSE = @verbose
99
+ end
100
+
101
+ it "executes the argument if it is a file that exists and is executable" do
102
+ code = "some/ruby/file.rb"
103
+ File.should_receive(:exists?).with(code).and_return(true)
104
+ File.should_receive(:executable?).with(code).and_return(true)
105
+ @script.should_receive(:`).with("ruby_spec_exe -w -Q some/ruby/file.rb")
106
+ @script.ruby_exe code
107
+ end
108
+
109
+ it "executes the argument with -e" do
110
+ code = %(some "real" 'ruby' code)
111
+ File.should_receive(:exists?).with(code).and_return(false)
112
+ @script.should_receive(:`).with(%(ruby_spec_exe -w -Q -e "some \\"real\\" 'ruby' code"))
113
+ @script.ruby_exe code
114
+ end
115
+ end
@@ -48,13 +48,13 @@ describe ActionFilter, "#load" do
48
48
  end
49
49
 
50
50
  it "creates a filter from a single tag" do
51
- MSpec.should_receive(:read_tags).with("tag").and_return([@tag])
51
+ MSpec.should_receive(:read_tags).with(["tag"]).and_return([@tag])
52
52
  MatchFilter.should_receive(:new).with(nil, "description")
53
53
  ActionFilter.new("tag", nil).load
54
54
  end
55
55
 
56
56
  it "creates a filter from an array of tags" do
57
- MSpec.should_receive(:read_tags).with("tag", "key").and_return([@tag])
57
+ MSpec.should_receive(:read_tags).with(["tag", "key"]).and_return([@tag])
58
58
  MatchFilter.should_receive(:new).with(nil, "description")
59
59
  ActionFilter.new(["tag", "key"], nil).load
60
60
  end
@@ -68,7 +68,7 @@ describe ActionFilter, "#load" do
68
68
  end
69
69
 
70
70
  describe ActionFilter, "#register" do
71
- it "registers itself with MSpec for the :load, :unload actions" do
71
+ it "registers itself with MSpec for the :load actions" do
72
72
  filter = ActionFilter.new
73
73
  MSpec.should_receive(:register).with(:load, filter)
74
74
  filter.register
@@ -76,7 +76,7 @@ describe ActionFilter, "#register" do
76
76
  end
77
77
 
78
78
  describe ActionFilter, "#unregister" do
79
- it "unregisters itself with MSpec for the :load, :unload actions" do
79
+ it "unregisters itself with MSpec for the :load actions" do
80
80
  filter = ActionFilter.new
81
81
  MSpec.should_receive(:unregister).with(:load, filter)
82
82
  filter.unregister
@@ -4,11 +4,7 @@ require 'mspec/runner/mspec'
4
4
  require 'mspec/runner/example'
5
5
  require 'mspec/runner/tag'
6
6
 
7
- describe TagAction do
8
- before :each do
9
- MSpec.stub!(:read_tags).and_return([])
10
- end
11
-
7
+ describe TagAction, ".new" do
12
8
  it "creates an MatchFilter with its tag and desc arguments" do
13
9
  filter = mock('action filter', :null_object => true)
14
10
  MatchFilter.should_receive(:new).with(nil, "some", "thing").and_return(filter)
@@ -0,0 +1,152 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require 'mspec/runner/actions/taglist'
3
+ require 'mspec/runner/mspec'
4
+ require 'mspec/runner/example'
5
+ require 'mspec/runner/tag'
6
+
7
+ describe TagListAction, "#include?" do
8
+ it "returns true" do
9
+ TagListAction.new.include?(:anything).should be_true
10
+ end
11
+ end
12
+
13
+ describe TagListAction, "#===" do
14
+ before :each do
15
+ tag = SpecTag.new "fails:description"
16
+ MSpec.stub!(:read_tags).and_return([tag])
17
+ @filter = mock("MatchFilter", :null_object => true)
18
+ MatchFilter.stub!(:new).and_return(@filter)
19
+ @action = TagListAction.new
20
+ @action.load
21
+ end
22
+
23
+ it "returns true if filter === string returns true" do
24
+ @filter.should_receive(:===).with("str").and_return(true)
25
+ @action.===("str").should be_true
26
+ end
27
+
28
+ it "returns false if filter === string returns false" do
29
+ @filter.should_receive(:===).with("str").and_return(false)
30
+ @action.===("str").should be_false
31
+ end
32
+ end
33
+
34
+ describe TagListAction, "#start" do
35
+ before :each do
36
+ @stdout = $stdout
37
+ $stdout = IOStub.new
38
+ end
39
+
40
+ after :each do
41
+ $stdout = @stdout
42
+ end
43
+
44
+ it "prints a banner for specific tags" do
45
+ action = TagListAction.new ["fails", "unstable"]
46
+ action.start
47
+ $stdout.should == "\nListing specs tagged with 'fails', 'unstable'\n\n"
48
+ end
49
+
50
+ it "prints a banner for all tags" do
51
+ action = TagListAction.new
52
+ action.start
53
+ $stdout.should == "\nListing all tagged specs\n\n"
54
+ end
55
+ end
56
+
57
+ describe TagListAction, "#laod" do
58
+ before :each do
59
+ @t1 = SpecTag.new "fails:I fail"
60
+ @t2 = SpecTag.new "unstable:I'm unstable"
61
+ end
62
+
63
+ it "creates a MatchFilter for matching tags" do
64
+ MSpec.should_receive(:read_tags).with(["fails"]).and_return([@t1])
65
+ MatchFilter.should_receive(:new).with(nil, "I fail")
66
+ TagListAction.new(["fails"]).load
67
+ end
68
+
69
+ it "creates a MatchFilter for all tags" do
70
+ MSpec.should_receive(:read_tags).and_return([@t1, @t2])
71
+ MatchFilter.should_receive(:new).with(nil, "I fail", "I'm unstable")
72
+ TagListAction.new.load
73
+ end
74
+
75
+ it "does not create a MatchFilter if there are no matching tags" do
76
+ MSpec.stub!(:read_tags).and_return([])
77
+ MatchFilter.should_not_receive(:new)
78
+ TagListAction.new(["fails"]).load
79
+ end
80
+ end
81
+
82
+ describe TagListAction, "#after" do
83
+ before :each do
84
+ @stdout = $stdout
85
+ $stdout = IOStub.new
86
+
87
+ @state = mock("ExampleState")
88
+ @state.stub!(:description).and_return("str")
89
+
90
+ @action = TagListAction.new
91
+ end
92
+
93
+ after :each do
94
+ $stdout = @stdout
95
+ end
96
+
97
+ it "prints nothing if the filter does not match" do
98
+ @action.should_receive(:===).with("str").and_return(false)
99
+ @action.after(@state)
100
+ $stdout.should == ""
101
+ end
102
+
103
+ it "prints the example description if the filter matches" do
104
+ @action.should_receive(:===).with("str").and_return(true)
105
+ @action.after(@state)
106
+ $stdout.should == "str\n"
107
+ end
108
+ end
109
+
110
+ describe TagListAction, "#register" do
111
+ before :each do
112
+ MSpec.stub!(:register)
113
+ @action = TagListAction.new
114
+ end
115
+
116
+ it "registers itself with MSpec for the :start event" do
117
+ MSpec.should_receive(:register).with(:start, @action)
118
+ @action.register
119
+ end
120
+
121
+ it "registers itself with MSpec for the :load event" do
122
+ MSpec.should_receive(:register).with(:load, @action)
123
+ @action.register
124
+ end
125
+
126
+ it "registers itself with MSpec for the :after event" do
127
+ MSpec.should_receive(:register).with(:after, @action)
128
+ @action.register
129
+ end
130
+ end
131
+
132
+ describe TagListAction, "#unregister" do
133
+ before :each do
134
+ MSpec.stub!(:unregister)
135
+ @action = TagListAction.new
136
+ end
137
+
138
+ it "unregisters itself with MSpec for the :start event" do
139
+ MSpec.should_receive(:unregister).with(:start, @action)
140
+ @action.unregister
141
+ end
142
+
143
+ it "unregisters itself with MSpec for the :load event" do
144
+ MSpec.should_receive(:unregister).with(:load, @action)
145
+ @action.unregister
146
+ end
147
+
148
+ it "unregisters itself with MSpec for the :after event" do
149
+ MSpec.should_receive(:unregister).with(:after, @action)
150
+ @action.unregister
151
+ end
152
+ end
@@ -13,7 +13,7 @@ describe TagFilter, "#load" do
13
13
  end
14
14
 
15
15
  it "loads tags from the tag file" do
16
- MSpec.should_receive(:read_tags).with("tag", "key").and_return([])
16
+ MSpec.should_receive(:read_tags).with(["tag", "key"]).and_return([])
17
17
  @filter.load
18
18
  end
19
19
 
@@ -368,7 +368,7 @@ describe MSpec, ".read_tags" do
368
368
 
369
369
  it "returns a list of tag instances for matching tag names found" do
370
370
  one = SpecTag.new "fail(broken):Some#method? works"
371
- MSpec.read_tags("fail", "pass").should == [one]
371
+ MSpec.read_tags(["fail", "pass"]).should == [one]
372
372
  end
373
373
 
374
374
  it "returns [] if no tags names match" do
data/spec/spec_helper.rb CHANGED
@@ -27,12 +27,13 @@ class MOSConfig < Hash
27
27
  self[:astrings] = []
28
28
  self[:target] = 'ruby'
29
29
  self[:command] = nil
30
+ self[:ltags] = []
30
31
  end
31
32
  end
32
33
 
33
34
  def new_option
34
35
  config = MOSConfig.new
35
- return MSpecOptions.new(config, "spec"), config
36
+ return MSpecOptions.new("spec", 20, config), config
36
37
  end
37
38
 
38
39
  # Just to have an exception name output not be "Exception"
@@ -4,9 +4,444 @@ require 'mspec/version'
4
4
  require 'mspec/runner/mspec'
5
5
  require 'mspec/runner/formatters'
6
6
 
7
- describe MSpecOptions, "#parser" do
8
- it "returns an OptionParser instance" do
9
- MSpecOptions.new({}, "spec").parser.should be_kind_of(OptionParser)
7
+ describe MSpecOption, ".new" do
8
+ before :each do
9
+ @opt = MSpecOption.new("-a", "--bdc", "ARG", "desc", :block)
10
+ end
11
+
12
+ it "sets the short attribute" do
13
+ @opt.short.should == "-a"
14
+ end
15
+
16
+ it "sets the long attribute" do
17
+ @opt.long.should == "--bdc"
18
+ end
19
+
20
+ it "sets the arg attribute" do
21
+ @opt.arg.should == "ARG"
22
+ end
23
+
24
+ it "sets the description attribute" do
25
+ @opt.description.should == "desc"
26
+ end
27
+
28
+ it "sets the block attribute" do
29
+ @opt.block.should == :block
30
+ end
31
+ end
32
+
33
+ describe MSpecOption, "#arg?" do
34
+ it "returns true if arg attribute is not nil" do
35
+ MSpecOption.new(nil, nil, "ARG", nil, nil).arg?.should be_true
36
+ end
37
+
38
+ it "returns false if arg attribute is nil" do
39
+ MSpecOption.new(nil, nil, nil, nil, nil).arg?.should be_false
40
+ end
41
+ end
42
+
43
+ describe MSpecOption, "#match?" do
44
+ before :each do
45
+ @opt = MSpecOption.new("-a", "--bdc", "ARG", "desc", :block)
46
+ end
47
+
48
+ it "returns true if the argument matches the short option" do
49
+ @opt.match?("-a").should be_true
50
+ end
51
+
52
+ it "returns true if the argument matches the long option" do
53
+ @opt.match?("--bdc").should be_true
54
+ end
55
+
56
+ it "returns false if the argument matches neither the short nor long option" do
57
+ @opt.match?("-b").should be_false
58
+ @opt.match?("-abdc").should be_false
59
+ end
60
+ end
61
+
62
+ describe MSpecOptions, ".new" do
63
+ before :each do
64
+ @opt = MSpecOptions.new("cmd", 20, :config)
65
+ end
66
+
67
+ it "sets the banner attribute" do
68
+ @opt.banner.should == "cmd"
69
+ end
70
+
71
+ it "sets the config attribute" do
72
+ @opt.config.should == :config
73
+ end
74
+
75
+ it "sets the width attribute" do
76
+ @opt.width.should == 20
77
+ end
78
+
79
+ it "sets the default width attribute" do
80
+ MSpecOptions.new.width.should == 30
81
+ end
82
+ end
83
+
84
+ describe MSpecOptions, "#on" do
85
+ before :each do
86
+ @opt = MSpecOptions.new
87
+ end
88
+
89
+ it "adds a short option" do
90
+ @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
91
+ @opt.on("-a", "desc")
92
+ end
93
+
94
+ it "adds a short option taking an argument" do
95
+ @opt.should_receive(:add).with("-a", nil, "ARG", "desc", nil)
96
+ @opt.on("-a", "ARG", "desc")
97
+ end
98
+
99
+ it "adds a long option" do
100
+ @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
101
+ @opt.on("-a", "desc")
102
+ end
103
+
104
+ it "adds a long option taking an argument" do
105
+ @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
106
+ @opt.on("-a", "desc")
107
+ end
108
+
109
+ it "adds a short and long option" do
110
+ @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
111
+ @opt.on("-a", "desc")
112
+ end
113
+
114
+ it "adds a short and long option taking an argument" do
115
+ @opt.should_receive(:add).with("-a", nil, nil, "desc", nil)
116
+ @opt.on("-a", "desc")
117
+ end
118
+
119
+ it "raises MSpecOptions::OptionError if pass less than 2 arguments" do
120
+ lambda { @opt.on }.should raise_error(MSpecOptions::OptionError)
121
+ lambda { @opt.on "" }.should raise_error(MSpecOptions::OptionError)
122
+ end
123
+ end
124
+
125
+ describe MSpecOptions, "#add" do
126
+ before :each do
127
+ @opt = MSpecOptions.new "cmd", 20
128
+ @prc = lambda { }
129
+ end
130
+
131
+ it "adds documentation for an option" do
132
+ @opt.should_receive(:doc).with(" -t, --typo ARG Correct typo ARG")
133
+ @opt.add("-t", "--typo", "ARG", "Correct typo ARG", @prc)
134
+ end
135
+
136
+ it "leaves spaces in the documentation for a missing short option" do
137
+ @opt.should_receive(:doc).with(" --typo ARG Correct typo ARG")
138
+ @opt.add(nil, "--typo", "ARG", "Correct typo ARG", @prc)
139
+ end
140
+
141
+ it "handles a short option with argument but no long argument" do
142
+ @opt.should_receive(:doc).with(" -t ARG Correct typo ARG")
143
+ @opt.add("-t", nil, "ARG", "Correct typo ARG", @prc)
144
+ end
145
+
146
+ it "registers an option" do
147
+ option = MSpecOption.new "-t", "--typo", "ARG", "Correct typo ARG", @prc
148
+ MSpecOption.should_receive(:new).with(
149
+ "-t", "--typo", "ARG", "Correct typo ARG", @prc).and_return(option)
150
+ @opt.add("-t", "--typo", "ARG", "Correct typo ARG", @prc)
151
+ @opt.options.should == [option]
152
+ end
153
+ end
154
+
155
+ describe MSpecOptions, "#match?" do
156
+ before :each do
157
+ @opt = MSpecOptions.new
158
+ end
159
+
160
+ it "returns the MSpecOption instance matching the argument" do
161
+ @opt.on "-a", "--abdc", "desc"
162
+ option = @opt.match? "-a"
163
+ @opt.match?("--abdc").should be(option)
164
+ option.should be_kind_of(MSpecOption)
165
+ option.short.should == "-a"
166
+ option.long.should == "--abdc"
167
+ option.description.should == "desc"
168
+ end
169
+ end
170
+
171
+ describe MSpecOptions, "#process" do
172
+ before :each do
173
+ @opt = MSpecOptions.new
174
+ ScratchPad.clear
175
+ end
176
+
177
+ it "calls the on_extra block if the argument does not match any option" do
178
+ @opt.on_extra { ScratchPad.record :extra }
179
+ @opt.process ["-a"], "-a", "-a", nil
180
+ ScratchPad.recorded.should == :extra
181
+ end
182
+
183
+ it "returns the matching option" do
184
+ @opt.on "-a", "ARG", "desc"
185
+ option = @opt.process [], "-a", "-a", "ARG"
186
+ option.should be_kind_of(MSpecOption)
187
+ option.short.should == "-a"
188
+ option.arg.should == "ARG"
189
+ option.description.should == "desc"
190
+ end
191
+
192
+ it "raises an MSpecOptions::ParseError if arg is nil and there are no more entries in argv" do
193
+ @opt.on "-a", "ARG", "desc"
194
+ lambda { @opt.process [], "-a", "-a", nil }.should raise_error(MSpecOptions::ParseError)
195
+ end
196
+
197
+ it "fetches the argument for the option from argv if arg is nil" do
198
+ @opt.on("-a", "ARG", "desc") { |o| ScratchPad.record o }
199
+ @opt.process ["ARG"], "-a", "-a", nil
200
+ ScratchPad.recorded.should == "ARG"
201
+ end
202
+
203
+ it "calls the option's block" do
204
+ @opt.on("-a", "ARG", "desc") { ScratchPad.record :option }
205
+ @opt.process [], "-a", "-a", "ARG"
206
+ ScratchPad.recorded.should == :option
207
+ end
208
+
209
+ it "does not call the option's block if it is nil" do
210
+ @opt.on "-a", "ARG", "desc"
211
+ lambda { @opt.process [], "-a", "-a", "ARG" }.should_not raise_error
212
+ end
213
+ end
214
+
215
+ describe MSpecOptions, "#split" do
216
+ before :each do
217
+ @opt = MSpecOptions.new
218
+ end
219
+
220
+ it "breaks a string at the nth character" do
221
+ opt, arg, rest = @opt.split "-bdc", 2
222
+ opt.should == "-b"
223
+ arg.should == "dc"
224
+ rest.should == "dc"
225
+ end
226
+
227
+ it "returns nil for arg if there are no characters left" do
228
+ opt, arg, rest = @opt.split "-b", 2
229
+ opt.should == "-b"
230
+ arg.should == nil
231
+ rest.should == ""
232
+ end
233
+ end
234
+
235
+ describe MSpecOptions, "#parse" do
236
+ before :each do
237
+ @opt = MSpecOptions.new
238
+ @prc = lambda { |o| ScratchPad.record [:parsed, o] }
239
+ ScratchPad.clear
240
+ end
241
+
242
+ it "parses a short option" do
243
+ @opt.on "-a", "desc", &@prc
244
+ @opt.parse ["-a"]
245
+ ScratchPad.recorded.should == [:parsed, nil]
246
+ end
247
+
248
+ it "parse a long option" do
249
+ @opt.on "--abdc", "desc", &@prc
250
+ @opt.parse ["--abdc"]
251
+ ScratchPad.recorded.should == [:parsed, nil]
252
+ end
253
+
254
+ it "parses a short option group" do
255
+ @opt.on "-a", "ARG", "desc", &@prc
256
+ @opt.parse ["-a", "ARG"]
257
+ ScratchPad.recorded.should == [:parsed, "ARG"]
258
+ end
259
+
260
+ it "parses a short option with an argument" do
261
+ @opt.on "-a", "ARG", "desc", &@prc
262
+ @opt.parse ["-a", "ARG"]
263
+ ScratchPad.recorded.should == [:parsed, "ARG"]
264
+ end
265
+
266
+ it "parses a short option with connected argument" do
267
+ @opt.on "-a", "ARG", "desc", &@prc
268
+ @opt.parse ["-aARG"]
269
+ ScratchPad.recorded.should == [:parsed, "ARG"]
270
+ end
271
+
272
+ it "parses a long option with an argument" do
273
+ @opt.on "--abdc", "ARG", "desc", &@prc
274
+ @opt.parse ["--abdc", "ARG"]
275
+ ScratchPad.recorded.should == [:parsed, "ARG"]
276
+ end
277
+
278
+ it "parses a long option with an '=' argument" do
279
+ @opt.on "--abdc", "ARG", "desc", &@prc
280
+ @opt.parse ["--abdc=ARG"]
281
+ ScratchPad.recorded.should == [:parsed, "ARG"]
282
+ end
283
+
284
+ it "parses a short option group with the final option taking an argument" do
285
+ ScratchPad.record []
286
+ @opt.on("-a", "desc") { |o| ScratchPad << :a }
287
+ @opt.on("-b", "ARG", "desc") { |o| ScratchPad << [:b, o] }
288
+ @opt.parse ["-ab", "ARG"]
289
+ ScratchPad.recorded.should == [:a, [:b, "ARG"]]
290
+ end
291
+
292
+ it "parses a short option group with a connected argument" do
293
+ ScratchPad.record []
294
+ @opt.on("-a", "desc") { |o| ScratchPad << :a }
295
+ @opt.on("-b", "ARG", "desc") { |o| ScratchPad << [:b, o] }
296
+ @opt.on("-c", "desc") { |o| ScratchPad << :c }
297
+ @opt.parse ["-acbARG"]
298
+ ScratchPad.recorded.should == [:a, :c, [:b, "ARG"]]
299
+ end
300
+
301
+ it "returns the unprocessed entries" do
302
+ @opt.on "-a", "ARG", "desc", &@prc
303
+ @opt.parse(["abdc", "-a", "ilny"]).should == ["abdc"]
304
+ end
305
+
306
+ it "calls the on_extra handler with unrecognized options" do
307
+ ScratchPad.record []
308
+ @opt.on_extra { |o| ScratchPad << o }
309
+ @opt.on "-a", "desc"
310
+ @opt.parse ["-a", "-b"]
311
+ ScratchPad.recorded.should == ["-b"]
312
+ end
313
+
314
+ it "does not attempt to call the block if it is nil" do
315
+ @opt.on "-a", "ARG", "desc"
316
+ @opt.parse(["-a", "ARG"]).should == []
317
+ end
318
+
319
+ it "raises MSpecOptions::ParseError if passed an unrecognized option" do
320
+ @opt.should_receive(:raise).with(MSpecOptions::ParseError, an_instance_of(String))
321
+ @opt.stub!(:puts)
322
+ @opt.stub!(:exit)
323
+ @opt.parse "-u"
324
+ end
325
+ end
326
+
327
+ describe MSpecOptions, "#banner=" do
328
+ before :each do
329
+ @opt = MSpecOptions.new
330
+ end
331
+
332
+ it "sets the banner attribute" do
333
+ @opt.banner.should == ""
334
+ @opt.banner = "banner"
335
+ @opt.banner.should == "banner"
336
+ end
337
+ end
338
+
339
+ describe MSpecOptions, "#width=" do
340
+ before :each do
341
+ @opt = MSpecOptions.new
342
+ end
343
+
344
+ it "sets the width attribute" do
345
+ @opt.width.should == 30
346
+ @opt.width = 20
347
+ @opt.width.should == 20
348
+ end
349
+ end
350
+
351
+ describe MSpecOptions, "#config=" do
352
+ before :each do
353
+ @opt = MSpecOptions.new
354
+ end
355
+
356
+ it "sets the config attribute" do
357
+ @opt.config.should be_nil
358
+ @opt.config = :config
359
+ @opt.config.should == :config
360
+ end
361
+ end
362
+
363
+ describe MSpecOptions, "#doc" do
364
+ before :each do
365
+ @opt = MSpecOptions.new "command"
366
+ end
367
+
368
+ it "adds text to be displayed with #to_s" do
369
+ @opt.doc "Some message"
370
+ @opt.doc "Another message"
371
+ @opt.to_s.should == <<-EOD
372
+ command
373
+
374
+ Some message
375
+ Another message
376
+ EOD
377
+ end
378
+ end
379
+
380
+ describe MSpecOptions, "#version" do
381
+ before :each do
382
+ @opt = MSpecOptions.new
383
+ ScratchPad.clear
384
+ end
385
+
386
+ it "installs a basic -v, --version option" do
387
+ @opt.should_receive(:puts)
388
+ @opt.should_receive(:exit)
389
+ @opt.version "1.0.0"
390
+ @opt.parse "-v"
391
+ end
392
+
393
+ it "accepts a block instead of using the default block" do
394
+ @opt.version("1.0.0") { |o| ScratchPad.record :version }
395
+ @opt.parse "-v"
396
+ ScratchPad.recorded.should == :version
397
+ end
398
+ end
399
+
400
+ describe MSpecOptions, "#help" do
401
+ before :each do
402
+ @opt = MSpecOptions.new
403
+ ScratchPad.clear
404
+ end
405
+
406
+ it "installs a basic -h, --help option" do
407
+ @opt.should_receive(:puts)
408
+ @opt.should_receive(:exit).with(1)
409
+ @opt.help
410
+ @opt.parse "-h"
411
+ end
412
+
413
+ it "accepts a block instead of using the default block" do
414
+ @opt.help { |o| ScratchPad.record :help }
415
+ @opt.parse "-h"
416
+ ScratchPad.recorded.should == :help
417
+ end
418
+ end
419
+
420
+ describe MSpecOptions, "#on_extra" do
421
+ before :each do
422
+ @opt = MSpecOptions.new
423
+ ScratchPad.clear
424
+ end
425
+
426
+ it "registers a block to be called when an option is not recognized" do
427
+ @opt.on_extra { ScratchPad.record :extra }
428
+ @opt.parse "-g"
429
+ ScratchPad.recorded.should == :extra
430
+ end
431
+ end
432
+
433
+ describe MSpecOptions, "#to_s" do
434
+ before :each do
435
+ @opt = MSpecOptions.new "command"
436
+ end
437
+
438
+ it "returns the banner and descriptive strings for all registered options" do
439
+ @opt.on "-t", "--this ARG", "Adds this ARG to the list"
440
+ @opt.to_s.should == <<-EOD
441
+ command
442
+
443
+ -t, --this ARG Adds this ARG to the list
444
+ EOD
10
445
  end
11
446
  end
12
447
 
@@ -15,17 +450,17 @@ describe "The -B, --config FILE option" do
15
450
  @options, @config = new_option
16
451
  end
17
452
 
18
- it "is enabled with #add_config { }" do
19
- @options.should_receive(:on).with("-B", "--config FILE",
20
- String, an_instance_of(String))
21
- @options.add_config {}
453
+ it "is enabled with #configure { }" do
454
+ @options.should_receive(:on).with("-B", "--config", "FILE",
455
+ an_instance_of(String))
456
+ @options.configure {}
22
457
  end
23
458
 
24
459
  it "calls the passed block" do
25
460
  ["-B", "--config"].each do |opt|
26
461
  ScratchPad.clear
27
462
 
28
- @options.add_config { |x| ScratchPad.record x }
463
+ @options.configure { |x| ScratchPad.record x }
29
464
  @options.parse [opt, "file"]
30
465
  ScratchPad.recorded.should == "file"
31
466
  end
@@ -42,15 +477,15 @@ describe "The -n, --name RUBY_NAME option" do
42
477
  $VERBOSE = @verbose
43
478
  end
44
479
 
45
- it "is enabled with #add_name" do
46
- @options.should_receive(:on).with("-n", "--name RUBY_NAME",
47
- String, an_instance_of(String))
48
- @options.add_name
480
+ it "is enabled with #name" do
481
+ @options.should_receive(:on).with("-n", "--name", "RUBY_NAME",
482
+ an_instance_of(String))
483
+ @options.name
49
484
  end
50
485
 
51
486
  it "sets RUBY_NAME when invoked" do
52
487
  Object.should_receive(:const_set).with(:RUBY_NAME, "name").twice
53
- @options.add_name
488
+ @options.name
54
489
  @options.parse ["-n", "name"]
55
490
  @options.parse ["--name", "name"]
56
491
  end
@@ -59,21 +494,20 @@ end
59
494
  describe "The -t, --target TARGET option" do
60
495
  before :each do
61
496
  @options, @config = new_option
62
- @options.add_targets
497
+ @options.targets
63
498
  end
64
499
 
65
- it "is enabled with #add_targets" do
500
+ it "is enabled with #targets" do
66
501
  @options.stub!(:on)
67
- @options.should_receive(:on).with("-t", "--target TARGET",
68
- String, an_instance_of(String))
69
- @options.add_targets
502
+ @options.should_receive(:on).with("-t", "--target", "TARGET",
503
+ an_instance_of(String))
504
+ @options.targets
70
505
  end
71
506
 
72
507
  it "sets the target to 'ruby' and flags to verbose with TARGET 'ruby'" do
73
508
  ["-t", "--target"].each do |opt|
74
509
  @options.parse [opt, "ruby"]
75
510
  @config[:target].should == "ruby"
76
- @config[:flags].should include("-v")
77
511
  end
78
512
  end
79
513
 
@@ -99,7 +533,7 @@ describe "The -t, --target TARGET option" do
99
533
  ["-t", "--target"].each do |opt|
100
534
  ["x", "rubinius"].each do |t|
101
535
  @options.parse [opt, t]
102
- @config[:target].should == "shotgun/rubinius"
536
+ @config[:target].should == "./bin/rbx"
103
537
  end
104
538
  end
105
539
  end
@@ -124,14 +558,14 @@ end
124
558
  describe "The -T, --target-opt OPT option" do
125
559
  before :each do
126
560
  @options, @config = new_option
127
- @options.add_targets
561
+ @options.targets
128
562
  end
129
563
 
130
- it "is enabled with #add_targets" do
564
+ it "is enabled with #targets" do
131
565
  @options.stub!(:on)
132
- @options.should_receive(:on).with("-T", "--target-opt OPT",
133
- String, an_instance_of(String))
134
- @options.add_targets
566
+ @options.should_receive(:on).with("-T", "--target-opt", "OPT",
567
+ an_instance_of(String))
568
+ @options.targets
135
569
  end
136
570
 
137
571
  it "adds OPT to flags" do
@@ -146,14 +580,14 @@ end
146
580
  describe "The -I, --include DIR option" do
147
581
  before :each do
148
582
  @options, @config = new_option
149
- @options.add_targets
583
+ @options.targets
150
584
  end
151
585
 
152
- it "is enabled with #add_targets" do
586
+ it "is enabled with #targets" do
153
587
  @options.stub!(:on)
154
- @options.should_receive(:on).with("-I", "--include DIR",
155
- String, an_instance_of(String))
156
- @options.add_targets
588
+ @options.should_receive(:on).with("-I", "--include", "DIR",
589
+ an_instance_of(String))
590
+ @options.targets
157
591
  end
158
592
 
159
593
  it "add DIR to the includes list" do
@@ -168,14 +602,14 @@ end
168
602
  describe "The -r, --require LIBRARY option" do
169
603
  before :each do
170
604
  @options, @config = new_option
171
- @options.add_targets
605
+ @options.targets
172
606
  end
173
607
 
174
- it "is enabled with #add_targets" do
608
+ it "is enabled with #targets" do
175
609
  @options.stub!(:on)
176
- @options.should_receive(:on).with("-r", "--require LIBRARY",
177
- String, an_instance_of(String))
178
- @options.add_targets
610
+ @options.should_receive(:on).with("-r", "--require", "LIBRARY",
611
+ an_instance_of(String))
612
+ @options.targets
179
613
  end
180
614
 
181
615
  it "adds LIBRARY to the requires list" do
@@ -190,14 +624,14 @@ end
190
624
  describe "The -f, --format FORMAT option" do
191
625
  before :each do
192
626
  @options, @config = new_option
193
- @options.add_formatters
627
+ @options.formatters
194
628
  end
195
629
 
196
- it "is enabled with #add_formatters" do
630
+ it "is enabled with #formatters" do
197
631
  @options.stub!(:on)
198
- @options.should_receive(:on).with("-f", "--format FORMAT",
199
- String, an_instance_of(String))
200
- @options.add_formatters
632
+ @options.should_receive(:on).with("-f", "--format", "FORMAT",
633
+ an_instance_of(String))
634
+ @options.formatters
201
635
  end
202
636
 
203
637
  it "sets the SpecdocFormatter with FORMAT 's' or 'specdoc'" do
@@ -264,14 +698,14 @@ end
264
698
  describe "The -o, --output FILE option" do
265
699
  before :each do
266
700
  @options, @config = new_option
267
- @options.add_formatters
701
+ @options.formatters
268
702
  end
269
703
 
270
- it "is enabled with #add_formatters" do
704
+ it "is enabled with #formatters" do
271
705
  @options.stub!(:on)
272
- @options.should_receive(:on).with("-o", "--output FILE",
273
- String, an_instance_of(String))
274
- @options.add_formatters
706
+ @options.should_receive(:on).with("-o", "--output", "FILE",
707
+ an_instance_of(String))
708
+ @options.formatters
275
709
  end
276
710
 
277
711
  it "sets the output to FILE" do
@@ -286,14 +720,14 @@ end
286
720
  describe "The -e, --example STR" do
287
721
  before :each do
288
722
  @options, @config = new_option
289
- @options.add_filters
723
+ @options.filters
290
724
  end
291
725
 
292
- it "is enabled with #add_filters" do
726
+ it "is enabled with #filters" do
293
727
  @options.stub!(:on)
294
- @options.should_receive(:on).with("-e", "--example STR",
295
- String, an_instance_of(String))
296
- @options.add_filters
728
+ @options.should_receive(:on).with("-e", "--example", "STR",
729
+ an_instance_of(String))
730
+ @options.filters
297
731
  end
298
732
 
299
733
  it "adds STR to the includes list" do
@@ -308,14 +742,14 @@ end
308
742
  describe "The -E, --exclude STR" do
309
743
  before :each do
310
744
  @options, @config = new_option
311
- @options.add_filters
745
+ @options.filters
312
746
  end
313
747
 
314
- it "is enabled with #add_filters" do
748
+ it "is enabled with #filters" do
315
749
  @options.stub!(:on)
316
- @options.should_receive(:on).with("-E", "--exclude STR",
317
- String, an_instance_of(String))
318
- @options.add_filters
750
+ @options.should_receive(:on).with("-E", "--exclude", "STR",
751
+ an_instance_of(String))
752
+ @options.filters
319
753
  end
320
754
 
321
755
  it "adds STR to the excludes list" do
@@ -330,14 +764,14 @@ end
330
764
  describe "The -p, --pattern PATTERN" do
331
765
  before :each do
332
766
  @options, @config = new_option
333
- @options.add_filters
767
+ @options.filters
334
768
  end
335
769
 
336
- it "is enabled with #add_filters" do
770
+ it "is enabled with #filters" do
337
771
  @options.stub!(:on)
338
- @options.should_receive(:on).with("-p", "--pattern PATTERN",
339
- Regexp, an_instance_of(String))
340
- @options.add_filters
772
+ @options.should_receive(:on).with("-p", "--pattern", "PATTERN",
773
+ an_instance_of(String))
774
+ @options.filters
341
775
  end
342
776
 
343
777
  it "adds PATTERN to the included patterns list" do
@@ -352,14 +786,14 @@ end
352
786
  describe "The -P, --excl-pattern PATTERN" do
353
787
  before :each do
354
788
  @options, @config = new_option
355
- @options.add_filters
789
+ @options.filters
356
790
  end
357
791
 
358
- it "is enabled with #add_filters" do
792
+ it "is enabled with #filters" do
359
793
  @options.stub!(:on)
360
- @options.should_receive(:on).with("-P", "--excl-pattern PATTERN",
361
- Regexp, an_instance_of(String))
362
- @options.add_filters
794
+ @options.should_receive(:on).with("-P", "--excl-pattern", "PATTERN",
795
+ an_instance_of(String))
796
+ @options.filters
363
797
  end
364
798
 
365
799
  it "adds PATTERN to the excluded patterns list" do
@@ -374,14 +808,14 @@ end
374
808
  describe "The -g, --tag TAG" do
375
809
  before :each do
376
810
  @options, @config = new_option
377
- @options.add_filters
811
+ @options.filters
378
812
  end
379
813
 
380
- it "is enabled with #add_filters" do
814
+ it "is enabled with #filters" do
381
815
  @options.stub!(:on)
382
- @options.should_receive(:on).with("-g", "--tag TAG",
383
- String, an_instance_of(String))
384
- @options.add_filters
816
+ @options.should_receive(:on).with("-g", "--tag", "TAG",
817
+ an_instance_of(String))
818
+ @options.filters
385
819
  end
386
820
 
387
821
  it "adds TAG to the included tags list" do
@@ -396,14 +830,14 @@ end
396
830
  describe "The -G, --excl-tag TAG" do
397
831
  before :each do
398
832
  @options, @config = new_option
399
- @options.add_filters
833
+ @options.filters
400
834
  end
401
835
 
402
- it "is enabled with #add_filters" do
836
+ it "is enabled with #filters" do
403
837
  @options.stub!(:on)
404
- @options.should_receive(:on).with("-G", "--excl-tag TAG",
405
- String, an_instance_of(String))
406
- @options.add_filters
838
+ @options.should_receive(:on).with("-G", "--excl-tag", "TAG",
839
+ an_instance_of(String))
840
+ @options.filters
407
841
  end
408
842
 
409
843
  it "adds TAG to the excluded tags list" do
@@ -418,14 +852,14 @@ end
418
852
  describe "The -w, --profile FILE option" do
419
853
  before :each do
420
854
  @options, @config = new_option
421
- @options.add_filters
855
+ @options.filters
422
856
  end
423
857
 
424
- it "is enabled with #add_filters" do
858
+ it "is enabled with #filters" do
425
859
  @options.stub!(:on)
426
- @options.should_receive(:on).with("-w", "--profile FILE",
427
- String, an_instance_of(String))
428
- @options.add_filters
860
+ @options.should_receive(:on).with("-w", "--profile", "FILE",
861
+ an_instance_of(String))
862
+ @options.filters
429
863
  end
430
864
 
431
865
  it "adds FILE to the included profiles list" do
@@ -440,14 +874,14 @@ end
440
874
  describe "The -W, --excl-profile FILE option" do
441
875
  before :each do
442
876
  @options, @config = new_option
443
- @options.add_filters
877
+ @options.filters
444
878
  end
445
879
 
446
- it "is enabled with #add_filters" do
880
+ it "is enabled with #filters" do
447
881
  @options.stub!(:on)
448
- @options.should_receive(:on).with("-W", "--excl-profile FILE",
449
- String, an_instance_of(String))
450
- @options.add_filters
882
+ @options.should_receive(:on).with("-W", "--excl-profile", "FILE",
883
+ an_instance_of(String))
884
+ @options.filters
451
885
  end
452
886
 
453
887
  it "adds FILE to the excluded profiles list" do
@@ -462,12 +896,12 @@ end
462
896
  describe "The -Z", "--dry-run option" do
463
897
  before :each do
464
898
  @options, @config = new_option
465
- @options.add_pretend
899
+ @options.pretend
466
900
  end
467
901
 
468
- it "is enabled with #add_pretend" do
902
+ it "is enabled with #pretend" do
469
903
  @options.should_receive(:on).with("-Z", "--dry-run", an_instance_of(String))
470
- @options.add_pretend
904
+ @options.pretend
471
905
  end
472
906
 
473
907
  it "registers the MSpec pretend mode" do
@@ -481,12 +915,12 @@ end
481
915
  describe "The -H, --random option" do
482
916
  before :each do
483
917
  @options, @config = new_option
484
- @options.add_randomize
918
+ @options.randomize
485
919
  end
486
920
 
487
- it "is enabled with #add_randomize" do
921
+ it "is enabled with #randomize" do
488
922
  @options.should_receive(:on).with("-H", "--random", an_instance_of(String))
489
- @options.add_randomize
923
+ @options.randomize
490
924
  end
491
925
 
492
926
  it "registers the MSpec randomize mode" do
@@ -500,13 +934,13 @@ end
500
934
  describe "The -V, --verbose option" do
501
935
  before :each do
502
936
  @options, @config = new_option
503
- @options.add_verbose
937
+ @options.verbose
504
938
  end
505
939
 
506
- it "is enabled with #add_verbose" do
940
+ it "is enabled with #verbose" do
507
941
  @options.stub!(:on)
508
942
  @options.should_receive(:on).with("-V", "--verbose", an_instance_of(String))
509
- @options.add_verbose
943
+ @options.verbose
510
944
  end
511
945
 
512
946
  it "registers a verbose output object with MSpec" do
@@ -521,14 +955,14 @@ end
521
955
  describe "The -m, --marker MARKER option" do
522
956
  before :each do
523
957
  @options, @config = new_option
524
- @options.add_verbose
958
+ @options.verbose
525
959
  end
526
960
 
527
- it "is enabled with #add_verbose" do
961
+ it "is enabled with #verbose" do
528
962
  @options.stub!(:on)
529
- @options.should_receive(:on).with("-m", "--marker MARKER",
530
- String, an_instance_of(String))
531
- @options.add_verbose
963
+ @options.should_receive(:on).with("-m", "--marker", "MARKER",
964
+ an_instance_of(String))
965
+ @options.verbose
532
966
  end
533
967
 
534
968
  it "registers a marker output object with MSpec" do
@@ -542,12 +976,12 @@ end
542
976
  describe "The --int-spec option" do
543
977
  before :each do
544
978
  @options, @config = new_option
545
- @options.add_interrupt
979
+ @options.interrupt
546
980
  end
547
981
 
548
- it "is enabled with #add_interrupt" do
982
+ it "is enabled with #interrupt" do
549
983
  @options.should_receive(:on).with("--int-spec", an_instance_of(String))
550
- @options.add_interrupt
984
+ @options.interrupt
551
985
  end
552
986
 
553
987
  it "sets the abort config option to false to only abort the running spec with ^C" do
@@ -560,17 +994,17 @@ end
560
994
  describe "The -Y, --verify option" do
561
995
  before :each do
562
996
  @options, @config = new_option
563
- @options.add_verify
997
+ @options.verify
564
998
  end
565
999
 
566
- it "is enabled with #add_interrupt" do
1000
+ it "is enabled with #interrupt" do
567
1001
  @options.stub!(:on)
568
1002
  @options.should_receive(:on).with("-Y", "--verify", an_instance_of(String))
569
- @options.add_verify
1003
+ @options.verify
570
1004
  end
571
1005
 
572
1006
  it "sets the MSpec mode to :verify" do
573
- MSpec.should_receive(:set_mode).with(:verify).twice
1007
+ MSpec.should_receive(:register_mode).with(:verify).twice
574
1008
  ["-Y", "--verify"].each do |m|
575
1009
  @options.parse m
576
1010
  end
@@ -580,147 +1014,34 @@ end
580
1014
  describe "The -O, --report option" do
581
1015
  before :each do
582
1016
  @options, @config = new_option
583
- @options.add_verify
1017
+ @options.verify
584
1018
  end
585
1019
 
586
- it "is enabled with #add_interrupt" do
1020
+ it "is enabled with #interrupt" do
587
1021
  @options.stub!(:on)
588
1022
  @options.should_receive(:on).with("-O", "--report", an_instance_of(String))
589
- @options.add_verify
1023
+ @options.verify
590
1024
  end
591
1025
 
592
1026
  it "sets the MSpec mode to :report" do
593
- MSpec.should_receive(:set_mode).with(:report).twice
1027
+ MSpec.should_receive(:register_mode).with(:report).twice
594
1028
  ["-O", "--report"].each do |m|
595
1029
  @options.parse m
596
1030
  end
597
1031
  end
598
1032
  end
599
1033
 
600
- describe "The -N, --add TAG option" do
601
- before :each do
602
- @options, @config = new_option
603
- @options.add_tagging
604
- end
605
-
606
- it "is enabled with #add_tagging" do
607
- @options.stub!(:on)
608
- @options.should_receive(:on).with("-N", "--add TAG",
609
- String, an_instance_of(String))
610
- @options.add_tagging
611
- end
612
-
613
- it "sets the mode to :add and sets the tag to TAG" do
614
- ["-N", "--add"].each do |opt|
615
- @config[:tagger] = nil
616
- @config[:tag] = nil
617
- @options.parse [opt, "taggit"]
618
- @config[:tagger].should == :add
619
- @config[:tag].should == "taggit:"
620
- end
621
- end
622
- end
623
-
624
- describe "The -R, --del TAG option" do
625
- before :each do
626
- @options, @config = new_option
627
- @options.add_tagging
628
- end
629
-
630
- it "is enabled with #add_tagging" do
631
- @options.stub!(:on)
632
- @options.should_receive(:on).with("-R", "--del TAG",
633
- String, an_instance_of(String))
634
- @options.add_tagging
635
- end
636
-
637
- it "it sets the mode to :del, the tag to TAG, and the outcome to :pass" do
638
- ["-R", "--del"].each do |opt|
639
- @config[:tagger] = nil
640
- @config[:tag] = nil
641
- @config[:outcome] = nil
642
- @options.parse [opt, "taggit"]
643
- @config[:tagger].should == :del
644
- @config[:tag].should == "taggit:"
645
- @config[:outcome].should == :pass
646
- end
647
- end
648
- end
649
-
650
- describe "The -Q, --pass option" do
651
- before :each do
652
- @options, @config = new_option
653
- @options.add_tagging
654
- end
655
-
656
- it "is enabled with #add_tagging" do
657
- @options.stub!(:on)
658
- @options.should_receive(:on).with("-Q", "--pass", an_instance_of(String))
659
- @options.add_tagging
660
- end
661
-
662
- it "sets the outcome to :pass" do
663
- ["-Q", "--pass"].each do |opt|
664
- @config[:outcome] = nil
665
- @options.parse opt
666
- @config[:outcome].should == :pass
667
- end
668
- end
669
- end
670
-
671
- describe "The -F, --fail option" do
672
- before :each do
673
- @options, @config = new_option
674
- @options.add_tagging
675
- end
676
-
677
- it "is enabled with #add_tagging" do
678
- @options.stub!(:on)
679
- @options.should_receive(:on).with("-F", "--fail", an_instance_of(String))
680
- @options.add_tagging
681
- end
682
-
683
- it "sets the outcome to :fail" do
684
- ["-F", "--fail"].each do |opt|
685
- @config[:outcome] = nil
686
- @options.parse opt
687
- @config[:outcome].should == :fail
688
- end
689
- end
690
- end
691
-
692
- describe "The -L, --all option" do
693
- before :each do
694
- @options, @config = new_option
695
- @options.add_tagging
696
- end
697
-
698
- it "is enabled with #add_tagging" do
699
- @options.stub!(:on)
700
- @options.should_receive(:on).with("-L", "--all", an_instance_of(String))
701
- @options.add_tagging
702
- end
703
-
704
- it "sets the outcome to :all" do
705
- ["-L", "--all"].each do |opt|
706
- @config[:outcome] = nil
707
- @options.parse opt
708
- @config[:outcome].should == :all
709
- end
710
- end
711
- end
712
-
713
1034
  describe "The -K, --action-tag TAG option" do
714
1035
  before :each do
715
1036
  @options, @config = new_option
716
- @options.add_action_filters
1037
+ @options.action_filters
717
1038
  end
718
1039
 
719
- it "is enabled with #add_action_filters" do
1040
+ it "is enabled with #action_filters" do
720
1041
  @options.stub!(:on)
721
- @options.should_receive(:on).with("-K", "--action-tag TAG",
722
- String, an_instance_of(String))
723
- @options.add_action_filters
1042
+ @options.should_receive(:on).with("-K", "--action-tag", "TAG",
1043
+ an_instance_of(String))
1044
+ @options.action_filters
724
1045
  end
725
1046
 
726
1047
  it "adds TAG to the list of tags that trigger actions" do
@@ -735,14 +1056,14 @@ end
735
1056
  describe "The -S, --action-string STR option" do
736
1057
  before :each do
737
1058
  @options, @config = new_option
738
- @options.add_action_filters
1059
+ @options.action_filters
739
1060
  end
740
1061
 
741
- it "is enabled with #add_action_filters" do
1062
+ it "is enabled with #action_filters" do
742
1063
  @options.stub!(:on)
743
- @options.should_receive(:on).with("-S", "--action-string STR",
744
- String, an_instance_of(String))
745
- @options.add_action_filters
1064
+ @options.should_receive(:on).with("-S", "--action-string", "STR",
1065
+ an_instance_of(String))
1066
+ @options.action_filters
746
1067
  end
747
1068
 
748
1069
  it "adds STR to the list of spec descriptions that trigger actions" do
@@ -757,17 +1078,17 @@ end
757
1078
  describe "The --spec-debug option" do
758
1079
  before :each do
759
1080
  @options, @config = new_option
760
- @options.add_actions
1081
+ @options.actions
761
1082
  end
762
1083
 
763
- it "is enabled with #add_actions" do
1084
+ it "is enabled with #actions" do
764
1085
  @options.stub!(:on)
765
1086
  @options.should_receive(:on).with("--spec-debug", an_instance_of(String))
766
- @options.add_actions
1087
+ @options.actions
767
1088
  end
768
1089
 
769
1090
  it "enables the triggering the ruby debugger" do
770
- @options.add_action_filters
1091
+ @options.action_filters
771
1092
  @options.parse ["-S", "some spec"]
772
1093
 
773
1094
  @config[:debugger] = nil
@@ -779,17 +1100,17 @@ end
779
1100
  describe "The --spec-gdb option" do
780
1101
  before :each do
781
1102
  @options, @config = new_option
782
- @options.add_actions
1103
+ @options.actions
783
1104
  end
784
1105
 
785
- it "is enabled with #add_actions" do
1106
+ it "is enabled with #actions" do
786
1107
  @options.stub!(:on)
787
1108
  @options.should_receive(:on).with("--spec-gdb", an_instance_of(String))
788
- @options.add_actions
1109
+ @options.actions
789
1110
  end
790
1111
 
791
1112
  it "enables triggering the gdb debugger" do
792
- @options.add_action_filters
1113
+ @options.action_filters
793
1114
  @options.parse ["-S", "some spec"]
794
1115
 
795
1116
  @config[:gdb] = nil
@@ -797,45 +1118,3 @@ describe "The --spec-gdb option" do
797
1118
  @config[:gdb].should == true
798
1119
  end
799
1120
  end
800
-
801
- describe "The -v, --version option" do
802
- before :each do
803
- @options, @config = new_option
804
- @options.add_version
805
- end
806
-
807
- it "is enabled with #add_version" do
808
- @options.stub!(:on)
809
- @options.should_receive(:on).with("-v", "--version", an_instance_of(String))
810
- @options.add_version
811
- end
812
-
813
- it "prints the version and exits" do
814
- @options.should_receive(:puts).twice
815
- @options.should_receive(:exit).twice
816
- ["-v", "--version"].each do |opt|
817
- @options.parse opt
818
- end
819
- end
820
- end
821
-
822
- describe "The -h, --help option" do
823
- before :each do
824
- @options, @config = new_option
825
- @options.add_help
826
- end
827
-
828
- it "is enabled with #add_help" do
829
- @options.stub!(:on)
830
- @options.should_receive(:on).with("-h", "--help", an_instance_of(String))
831
- @options.add_help
832
- end
833
-
834
- it "prints help and exits" do
835
- @options.should_receive(:puts).twice
836
- @options.should_receive(:exit).twice
837
- ["-h", "--help"].each do |opt|
838
- @options.parse opt
839
- end
840
- end
841
- end