dchelimsky-rspec 1.1.11 → 1.1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -0
- data/History.txt +19 -3
- data/Manifest.txt +6 -1
- data/examples/failing/README.txt +7 -0
- data/examples/failing/diffing_spec.rb +36 -0
- data/examples/failing/failing_autogenerated_docstrings_example.rb +19 -0
- data/examples/failing/failure_in_setup.rb +10 -0
- data/examples/failing/failure_in_teardown.rb +10 -0
- data/examples/failing/mocking_example.rb +40 -0
- data/examples/failing/mocking_with_flexmock.rb +26 -0
- data/examples/failing/mocking_with_mocha.rb +25 -0
- data/examples/failing/mocking_with_rr.rb +27 -0
- data/examples/failing/partial_mock_example.rb +20 -0
- data/examples/failing/predicate_example.rb +34 -0
- data/examples/failing/raising_example.rb +47 -0
- data/examples/failing/spec_helper.rb +3 -0
- data/examples/failing/syntax_error_example.rb +7 -0
- data/examples/failing/team_spec.rb +44 -0
- data/examples/failing/timeout_behaviour.rb +7 -0
- data/examples/passing/custom_formatter.rb +1 -1
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/lib/autotest/rspec.rb +1 -1
- data/lib/spec/dsl/main.rb +82 -0
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/example/before_and_after_hooks.rb +2 -1
- data/lib/spec/example/configuration.rb +1 -1
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +2 -1
- data/lib/spec/example/example_group_methods.rb +40 -25
- data/lib/spec/example/example_methods.rb +19 -8
- data/lib/spec/example.rb +15 -17
- data/lib/spec/expectations/handler.rb +23 -28
- data/lib/spec/expectations/wrap_expectation.rb +56 -0
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/extensions.rb +0 -1
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +6 -24
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +23 -46
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +2 -1
- data/lib/spec/matchers/throw_symbol.rb +9 -3
- data/lib/spec/mocks/message_expectation.rb +0 -5
- data/lib/spec/mocks/proxy.rb +12 -10
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/runner/formatter/base_text_formatter.rb +3 -2
- data/lib/spec/runner/option_parser.rb +4 -6
- data/lib/spec/runner/spec_parser.rb +5 -5
- data/lib/spec/runner.rb +37 -39
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +3 -1
- data/lib/spec.rb +21 -19
- data/rspec.gemspec +15 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +0 -37
- data/spec/spec/dsl/main_spec.rb +65 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +2 -1
- data/spec/spec/example/example_group_methods_spec.rb +138 -141
- data/spec/spec/example/example_group_spec.rb +3 -5
- data/spec/spec/example/example_methods_spec.rb +60 -23
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/description_generation_spec.rb +1 -1
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/throw_symbol_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +4 -14
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +1 -1
- data/spec/spec/runner/options_spec.rb +1 -1
- data/spec/spec/runner/spec_parser_spec.rb +76 -80
- data/spec/spec_helper.rb +4 -0
- data/stories/example_groups/autogenerated_docstrings +4 -4
- data/stories/interop/test_but_not_test_unit +14 -0
- data/stories/resources/helpers/story_helper.rb +1 -1
- data/stories/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +34 -53
- data/lib/spec/extensions/metaclass.rb +0 -7
@@ -3,8 +3,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
class ExampleGroupSubclass < ExampleGroup
|
6
|
-
|
7
|
-
|
6
|
+
def self.examples_ran
|
7
|
+
@examples_ran
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.examples_ran=(examples_ran)
|
11
|
+
@examples_ran = examples_ran
|
8
12
|
end
|
9
13
|
|
10
14
|
@@class_variable = :class_variable
|
@@ -16,12 +16,8 @@ module Spec
|
|
16
16
|
describe("ExampleGroup")
|
17
17
|
it "does nothing"
|
18
18
|
end
|
19
|
-
class << example_group
|
20
|
-
public :include
|
21
|
-
end
|
22
|
-
@result = nil
|
23
19
|
end
|
24
|
-
|
20
|
+
|
25
21
|
after(:each) do
|
26
22
|
ExampleGroup.reset
|
27
23
|
end
|
@@ -29,93 +25,84 @@ module Spec
|
|
29
25
|
["describe","context"].each do |method|
|
30
26
|
describe "##{method}" do
|
31
27
|
describe "when creating an ExampleGroup" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
28
|
+
before(:each) do
|
29
|
+
@parent_example_group = Class.new(ExampleGroup) do
|
30
|
+
example "first example" do; end
|
31
|
+
end
|
32
|
+
@child_example_group = @parent_example_group.__send__ method, "Child" do
|
33
|
+
example "second example" do; end
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
41
37
|
it "should create a subclass of the ExampleGroup when passed a block" do
|
42
|
-
child_example_group.superclass.should == @
|
43
|
-
|
38
|
+
@child_example_group.superclass.should == @parent_example_group
|
39
|
+
options.example_groups.should include(@child_example_group)
|
44
40
|
end
|
45
41
|
|
46
42
|
it "should not inherit examples" do
|
47
|
-
child_example_group.
|
43
|
+
@child_example_group.should have(1).examples
|
48
44
|
end
|
49
45
|
end
|
50
46
|
|
51
47
|
describe "when creating a SharedExampleGroup" do
|
52
|
-
attr_reader :name, :shared_example_group
|
53
48
|
before(:each) do
|
54
|
-
@
|
55
|
-
@shared_example_group = @example_group.send method, name, :shared => true do
|
56
|
-
it "should pass" do
|
57
|
-
true.should be_true
|
58
|
-
end
|
59
|
-
end
|
49
|
+
@shared_example_group = @example_group.__send__ method, "A Shared ExampleGroup", :shared => true do; end
|
60
50
|
end
|
61
51
|
|
62
52
|
after(:each) do
|
63
|
-
SharedExampleGroup.
|
53
|
+
SharedExampleGroup.instance_eval{@shared_example_groups}.delete @shared_example_group
|
64
54
|
end
|
65
55
|
|
66
56
|
it "should create a SharedExampleGroup" do
|
67
|
-
|
57
|
+
@shared_example_group.should_not be_nil
|
58
|
+
SharedExampleGroup.find("A Shared ExampleGroup").should == @shared_example_group
|
68
59
|
end
|
69
60
|
end
|
70
61
|
|
71
62
|
end
|
72
63
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
64
|
+
|
65
|
+
[:specify, :it].each do |method|
|
66
|
+
describe "##{method.to_s}" do
|
67
|
+
it "should should create an example" do
|
68
|
+
lambda {
|
69
|
+
@example_group.__send__(method, "")
|
70
|
+
}.should change { @example_group.examples.length }.by(1)
|
71
|
+
end
|
79
72
|
end
|
80
73
|
end
|
74
|
+
|
75
|
+
[:xit, :xspecify].each do |method|
|
76
|
+
describe "##{method.to_s}" do
|
77
|
+
before(:each) do
|
78
|
+
Kernel.stub!(:warn)
|
79
|
+
end
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
it "should NOT create an example instance" do
|
88
|
-
lambda {
|
89
|
-
@example_group.xit("")
|
90
|
-
}.should_not change(@example_group.examples, :length)
|
91
|
-
|
92
|
-
lambda {
|
93
|
-
@example_group.xspecify("")
|
94
|
-
}.should_not change(@example_group.examples, :length)
|
95
|
-
end
|
81
|
+
it "should NOT create an example" do
|
82
|
+
lambda {
|
83
|
+
@example_group.__send__(method,"")
|
84
|
+
}.should_not change(@example_group.examples, :length)
|
85
|
+
end
|
96
86
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
87
|
+
it "should warn that the example is disabled" do
|
88
|
+
Kernel.should_receive(:warn).with("Example disabled: foo")
|
89
|
+
@example_group.__send__(method,"foo")
|
90
|
+
end
|
101
91
|
end
|
102
92
|
end
|
93
|
+
|
103
94
|
|
104
95
|
describe "#examples" do
|
105
96
|
it "should have Examples" do
|
106
97
|
example_group = Class.new(ExampleGroup) do
|
107
|
-
|
108
|
-
it "should pass" do
|
109
|
-
1.should == 1
|
110
|
-
end
|
98
|
+
it "should exist" do; end
|
111
99
|
end
|
112
100
|
example_group.examples.length.should == 1
|
113
|
-
example_group.examples.first.description.should == "should
|
101
|
+
example_group.examples.first.description.should == "should exist"
|
114
102
|
end
|
115
103
|
|
116
104
|
it "should not include methods that begin with test (only when TU interop is loaded)" do
|
117
105
|
example_group = Class.new(ExampleGroup) do
|
118
|
-
describe('example')
|
119
106
|
def test_any_args(*args)
|
120
107
|
true.should be_true
|
121
108
|
end
|
@@ -138,7 +125,6 @@ module Spec
|
|
138
125
|
|
139
126
|
it "should include methods that begin with should and has an arity of 0 in suite" do
|
140
127
|
example_group = Class.new(ExampleGroup) do
|
141
|
-
describe('example')
|
142
128
|
def shouldCamelCase
|
143
129
|
true.should be_true
|
144
130
|
end
|
@@ -158,20 +144,21 @@ module Spec
|
|
158
144
|
raise "This is not a real example"
|
159
145
|
end
|
160
146
|
end
|
161
|
-
example_group
|
162
|
-
example_group.examples.
|
163
|
-
descriptions
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
descriptions.should_not include(
|
169
|
-
|
147
|
+
example_group.should have(4).examples
|
148
|
+
descriptions = example_group.examples.collect {|example| example.description}
|
149
|
+
descriptions.should include(
|
150
|
+
"shouldCamelCase",
|
151
|
+
"should_any_args",
|
152
|
+
"should_something",
|
153
|
+
"should_not_something")
|
154
|
+
descriptions.should_not include(
|
155
|
+
"should",
|
156
|
+
"should_not"
|
157
|
+
)
|
170
158
|
end
|
171
159
|
|
172
160
|
it "should not include methods that begin with test_ and has an arity > 0 in suite" do
|
173
161
|
example_group = Class.new(ExampleGroup) do
|
174
|
-
describe('example')
|
175
162
|
def test_invalid(foo)
|
176
163
|
1.should == 1
|
177
164
|
end
|
@@ -179,12 +166,11 @@ module Spec
|
|
179
166
|
1.should == 1
|
180
167
|
end
|
181
168
|
end
|
182
|
-
example_group.
|
169
|
+
example_group.should have(:no).examples
|
183
170
|
end
|
184
171
|
|
185
172
|
it "should not include methods that begin with should_ and has an arity > 0 in suite" do
|
186
173
|
example_group = Class.new(ExampleGroup) do
|
187
|
-
describe('example')
|
188
174
|
def should_invalid(foo)
|
189
175
|
1.should == 2
|
190
176
|
end
|
@@ -198,7 +184,7 @@ module Spec
|
|
198
184
|
1.should == 1
|
199
185
|
end
|
200
186
|
end
|
201
|
-
example_group.
|
187
|
+
example_group.should have(1).examples
|
202
188
|
example_group.run.should be_true
|
203
189
|
end
|
204
190
|
|
@@ -208,7 +194,7 @@ module Spec
|
|
208
194
|
1.should == 2
|
209
195
|
end
|
210
196
|
end
|
211
|
-
example_group.
|
197
|
+
example_group.should have(1).examples
|
212
198
|
example_group.run.should be_false
|
213
199
|
end
|
214
200
|
end
|
@@ -221,7 +207,7 @@ module Spec
|
|
221
207
|
end
|
222
208
|
end
|
223
209
|
|
224
|
-
describe "
|
210
|
+
describe "given a String" do
|
225
211
|
before(:each) do
|
226
212
|
example_group.set_description("abc")
|
227
213
|
end
|
@@ -235,7 +221,7 @@ module Spec
|
|
235
221
|
end
|
236
222
|
end
|
237
223
|
|
238
|
-
describe "
|
224
|
+
describe "given a Class" do
|
239
225
|
before(:each) do
|
240
226
|
example_group.set_description(ExampleGroup)
|
241
227
|
end
|
@@ -249,7 +235,7 @@ module Spec
|
|
249
235
|
end
|
250
236
|
end
|
251
237
|
|
252
|
-
describe "
|
238
|
+
describe "given a String and a Class" do
|
253
239
|
before(:each) do
|
254
240
|
example_group.set_description("behaving", ExampleGroup)
|
255
241
|
end
|
@@ -263,7 +249,7 @@ module Spec
|
|
263
249
|
end
|
264
250
|
end
|
265
251
|
|
266
|
-
describe "
|
252
|
+
describe "given a Class and a String (starting with an alpha char)" do
|
267
253
|
before(:each) do
|
268
254
|
example_group.set_description(ExampleGroup, "behaving")
|
269
255
|
end
|
@@ -273,7 +259,7 @@ module Spec
|
|
273
259
|
end
|
274
260
|
end
|
275
261
|
|
276
|
-
describe "
|
262
|
+
describe "given a Class and a String (starting with a '.')" do
|
277
263
|
before(:each) do
|
278
264
|
example_group.set_description(ExampleGroup, ".behaving")
|
279
265
|
end
|
@@ -375,7 +361,11 @@ module Spec
|
|
375
361
|
end
|
376
362
|
|
377
363
|
it "should return an Array of the description args from each class in the hierarchy" do
|
378
|
-
|
364
|
+
parent_example_group = Class.new(ExampleGroup) do
|
365
|
+
describe("Parent")
|
366
|
+
end
|
367
|
+
|
368
|
+
child_example_group = Class.new(parent_example_group)
|
379
369
|
child_example_group.describe("Child", ExampleGroup)
|
380
370
|
child_example_group.description.should_not be_empty
|
381
371
|
|
@@ -384,7 +374,7 @@ module Spec
|
|
384
374
|
grand_child_example_group.description.should_not be_empty
|
385
375
|
|
386
376
|
grand_child_example_group.description_parts.should == [
|
387
|
-
"
|
377
|
+
"Parent",
|
388
378
|
"Child",
|
389
379
|
Spec::Example::ExampleGroup,
|
390
380
|
"GrandChild",
|
@@ -415,64 +405,49 @@ module Spec
|
|
415
405
|
describe "#remove_after" do
|
416
406
|
it "should unregister a given after(:each) block" do
|
417
407
|
after_all_ran = false
|
418
|
-
@example_group.it("example") {}
|
419
408
|
proc = Proc.new { after_all_ran = true }
|
420
|
-
|
421
|
-
|
409
|
+
|
410
|
+
example_group = Class.new(ExampleGroup) do
|
411
|
+
specify("example") {}
|
412
|
+
after(:each, &proc)
|
413
|
+
end
|
414
|
+
|
415
|
+
example_group.run
|
422
416
|
after_all_ran.should be_true
|
423
417
|
|
424
418
|
after_all_ran = false
|
425
|
-
|
426
|
-
|
419
|
+
example_group.remove_after(:each, &proc)
|
420
|
+
example_group.run
|
427
421
|
after_all_ran.should be_false
|
428
422
|
end
|
429
423
|
end
|
430
424
|
|
431
425
|
describe "#include" do
|
432
426
|
it "should have accessible class methods from included module" do
|
433
|
-
|
434
|
-
|
435
|
-
extend Spec::MetaClass
|
436
|
-
class_methods = Module.new do
|
437
|
-
define_method :mod1_method do
|
438
|
-
mod1_method_called = true
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
metaclass.class_eval do
|
443
|
-
define_method(:included) do |receiver|
|
444
|
-
receiver.extend class_methods
|
445
|
-
end
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
mod2_method_called = false
|
450
|
-
mod2 = Module.new do
|
451
|
-
extend Spec::MetaClass
|
427
|
+
mod_method_called = false
|
428
|
+
mod = Module.new do
|
452
429
|
class_methods = Module.new do
|
453
|
-
define_method :
|
454
|
-
|
430
|
+
define_method :mod_method do
|
431
|
+
mod_method_called = true
|
455
432
|
end
|
456
433
|
end
|
457
434
|
|
458
|
-
|
435
|
+
self.class.class_eval do
|
459
436
|
define_method(:included) do |receiver|
|
460
437
|
receiver.extend class_methods
|
461
438
|
end
|
462
439
|
end
|
463
440
|
end
|
464
441
|
|
465
|
-
@example_group.include
|
442
|
+
@example_group.__send__ :include, mod
|
466
443
|
|
467
|
-
@example_group.
|
468
|
-
|
469
|
-
mod1_method_called.should be_true
|
470
|
-
mod2_method_called.should be_true
|
444
|
+
@example_group.mod_method
|
445
|
+
mod_method_called.should be_true
|
471
446
|
end
|
472
447
|
end
|
473
448
|
|
474
449
|
describe "#number_of_examples" do
|
475
|
-
it "should count number of
|
450
|
+
it "should count number of examples" do
|
476
451
|
proc do
|
477
452
|
@example_group.it("one") {}
|
478
453
|
@example_group.it("two") {}
|
@@ -485,58 +460,54 @@ module Spec
|
|
485
460
|
describe "#class_eval" do
|
486
461
|
it "should allow constants to be defined" do
|
487
462
|
example_group = Class.new(ExampleGroup) do
|
488
|
-
describe('example')
|
489
463
|
FOO = 1
|
490
464
|
it "should reference FOO" do
|
491
465
|
FOO.should == 1
|
492
466
|
end
|
493
467
|
end
|
494
|
-
example_group.run
|
468
|
+
success = example_group.run
|
469
|
+
success.should be_true
|
495
470
|
Object.const_defined?(:FOO).should == false
|
496
471
|
end
|
497
472
|
end
|
498
473
|
|
499
474
|
describe '#register' do
|
475
|
+
after(:each) do
|
476
|
+
example_group.unregister
|
477
|
+
end
|
500
478
|
it "should add ExampleGroup to set of ExampleGroups to be run" do
|
501
|
-
|
502
|
-
options.example_groups.should_not include(example_group)
|
503
|
-
|
504
|
-
example_group.register {}
|
479
|
+
example_group.register
|
505
480
|
options.example_groups.should include(example_group)
|
506
481
|
end
|
507
482
|
end
|
508
483
|
|
509
484
|
describe '#unregister' do
|
510
|
-
before do
|
511
|
-
|
485
|
+
before(:each) do
|
486
|
+
example_group.register
|
512
487
|
end
|
513
|
-
|
514
488
|
it "should remove ExampleGroup from set of ExampleGroups to be run" do
|
515
489
|
example_group.unregister
|
516
490
|
options.example_groups.should_not include(example_group)
|
517
491
|
end
|
518
492
|
end
|
519
|
-
|
520
|
-
describe "#registration_backtrace" do
|
521
|
-
it "returns the backtrace of where the ExampleGroup was registered" do
|
522
|
-
example_group = Class.new(ExampleGroup)
|
523
|
-
example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
524
|
-
end
|
525
|
-
end
|
526
493
|
|
527
494
|
describe "#run" do
|
528
|
-
|
529
|
-
|
530
|
-
|
495
|
+
describe "given an example group with at least one example" do
|
496
|
+
it "should call add_example_group" do
|
497
|
+
example_group = Class.new(ExampleGroup) do
|
498
|
+
example("anything") {}
|
499
|
+
end
|
500
|
+
reporter.should_receive(:add_example_group)
|
501
|
+
example_group.run
|
531
502
|
end
|
532
|
-
reporter.should_receive(:add_example_group)
|
533
|
-
example_group.run
|
534
503
|
end
|
535
504
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
505
|
+
describe "given an example group with no examples" do
|
506
|
+
it "should NOT call add_example_group" do
|
507
|
+
example_group = Class.new(ExampleGroup) do end
|
508
|
+
reporter.should_not_receive(:add_example_group)
|
509
|
+
example_group.run
|
510
|
+
end
|
540
511
|
end
|
541
512
|
end
|
542
513
|
|
@@ -544,13 +515,11 @@ module Spec
|
|
544
515
|
it "should call new and matches? on the class used for matching examples" do
|
545
516
|
example_group = Class.new(ExampleGroup) do
|
546
517
|
it "should do something" do end
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
"TestMatcher"
|
553
|
-
end
|
518
|
+
def self.specified_examples
|
519
|
+
["something"]
|
520
|
+
end
|
521
|
+
def self.to_s
|
522
|
+
"TestMatcher"
|
554
523
|
end
|
555
524
|
end
|
556
525
|
|
@@ -576,7 +545,35 @@ module Spec
|
|
576
545
|
group.options[:this].should == 'hash'
|
577
546
|
end
|
578
547
|
end
|
548
|
+
|
549
|
+
describe "#backtrace" do
|
550
|
+
it "returns the backtrace from where the example group was defined" do
|
551
|
+
example_group = Class.new(ExampleGroup).describe("foo") do
|
552
|
+
example "bar" do; end
|
553
|
+
end
|
554
|
+
example_group.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
describe "#example_group_backtrace (deprecated)" do
|
559
|
+
before(:each) do
|
560
|
+
Kernel.stub!(:warn)
|
561
|
+
end
|
562
|
+
it "sends a deprecation warning" do
|
563
|
+
example_group = Class.new(ExampleGroup) {}
|
564
|
+
Kernel.should_receive(:warn).with(/#example_group_backtrace.*deprecated.*#backtrace instead/m)
|
565
|
+
example_group.example_group_backtrace
|
566
|
+
end
|
567
|
+
|
568
|
+
it "returns the backtrace from where the example group was defined" do
|
569
|
+
example_group = Class.new(ExampleGroup).describe("foo") do
|
570
|
+
example "bar" do; end
|
571
|
+
end
|
572
|
+
example_group.example_group_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
579
576
|
end
|
580
577
|
end
|
581
578
|
end
|
582
|
-
end
|
579
|
+
end
|
@@ -449,10 +449,8 @@ module Spec
|
|
449
449
|
|
450
450
|
it "should use a mock framework set up in config" do
|
451
451
|
mod = Module.new do
|
452
|
-
|
453
|
-
|
454
|
-
$included_module = mod
|
455
|
-
end
|
452
|
+
def self.included(mod)
|
453
|
+
$included_module = mod
|
456
454
|
end
|
457
455
|
|
458
456
|
def teardown_mocks_for_rspec
|
@@ -661,7 +659,7 @@ module Spec
|
|
661
659
|
example_group = Class.new(ExampleSubclass) do
|
662
660
|
describe(Array)
|
663
661
|
end
|
664
|
-
example_group.
|
662
|
+
example_group.__send__(:described_type).should == Array
|
665
663
|
end
|
666
664
|
|
667
665
|
it "should concat descriptions when nested" do
|
@@ -134,14 +134,40 @@ module Spec
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
describe "#
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
describe "#backtrace" do
|
138
|
+
with_sandboxed_options do
|
139
|
+
it "returns the backtrace from where the example was defined" do
|
140
|
+
example_group = Class.new(ExampleGroup) do
|
141
|
+
example "of something" do; end
|
141
142
|
end
|
143
|
+
|
144
|
+
example = example_group.examples.first
|
145
|
+
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "#implementation_backtrace (deprecated)" do
|
151
|
+
with_sandboxed_options do
|
152
|
+
before(:each) do
|
153
|
+
Kernel.stub!(:warn)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "sends a deprecation warning" do
|
157
|
+
example_group = Class.new(ExampleGroup) {}
|
158
|
+
example = example_group.example("") {}
|
159
|
+
Kernel.should_receive(:warn).with(/#implementation_backtrace.*deprecated.*#backtrace instead/m)
|
160
|
+
example.implementation_backtrace
|
161
|
+
end
|
162
|
+
|
163
|
+
it "returns the backtrace from where the example was defined" do
|
164
|
+
example_group = Class.new(ExampleGroup) do
|
165
|
+
example "of something" do; end
|
166
|
+
end
|
167
|
+
|
168
|
+
example = example_group.examples.first
|
169
|
+
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
142
170
|
end
|
143
|
-
example = example_group.examples.first
|
144
|
-
example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-4}")
|
145
171
|
end
|
146
172
|
end
|
147
173
|
|
@@ -157,26 +183,37 @@ module Spec
|
|
157
183
|
end
|
158
184
|
|
159
185
|
describe "#subject" do
|
160
|
-
|
161
|
-
|
162
|
-
|
186
|
+
with_sandboxed_options do
|
187
|
+
it "should return an instance variable named after the described type" do
|
188
|
+
example_group = Class.new(ExampleGroup).describe(Array) do
|
189
|
+
example {}
|
190
|
+
end
|
191
|
+
example = example_group.examples.first
|
192
|
+
example.subject.should == []
|
163
193
|
end
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
example {}
|
194
|
+
|
195
|
+
it "should not barf on a module (as opposed to a class)" do
|
196
|
+
example_group = Class.new(ExampleGroup).describe(ObjectSpace) do
|
197
|
+
example {}
|
198
|
+
end
|
199
|
+
example_group.examples.first.subject.should be_nil
|
171
200
|
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
201
|
+
|
202
|
+
it "should not barf on a string" do
|
203
|
+
example_group = Class.new(ExampleGroup).describe('foo') do
|
204
|
+
example {}
|
205
|
+
end
|
206
|
+
example_group.examples.first.subject.should be_nil
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should interact with the same scope as the before block" do
|
210
|
+
example_group = Class.new(ExampleGroup) do
|
211
|
+
subject { @foo = 'foo'}
|
212
|
+
example { should == @foo}
|
213
|
+
it { should == 'foo'}
|
214
|
+
end
|
215
|
+
example_group.run.should be_true
|
178
216
|
end
|
179
|
-
example_group.examples.first.subject.should be_nil
|
180
217
|
end
|
181
218
|
end
|
182
219
|
|