rspec 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +35 -0
- data/MIT-LICENSE +1 -1
- data/README +9 -44
- data/Rakefile +34 -51
- data/TODO +0 -1
- data/UPGRADE +0 -24
- data/bin/spec +0 -0
- data/bin/spec_translator +0 -0
- data/examples/pure/behave_as_example.rb +0 -0
- data/examples/pure/partial_mock_example.rb +1 -0
- data/examples/stories/calculator.rb +1 -1
- data/lib/autotest/rspec.rb +7 -9
- data/lib/spec/example.rb +1 -1
- data/lib/spec/example/configuration.rb +30 -16
- data/lib/spec/example/example_group.rb +2 -1
- data/lib/spec/example/example_group_factory.rb +23 -21
- data/lib/spec/example/example_group_methods.rb +18 -5
- data/lib/spec/example/example_matcher.rb +0 -0
- data/lib/spec/example/example_methods.rb +6 -0
- data/lib/spec/example/module_inclusion_warnings.rb +37 -0
- data/lib/spec/expectations/differs/default.rb +1 -1
- data/lib/spec/expectations/extensions/object.rb +4 -12
- data/lib/spec/expectations/handler.rb +8 -0
- data/lib/spec/extensions.rb +1 -0
- data/lib/spec/extensions/metaclass.rb +7 -0
- data/lib/spec/extensions/object.rb +0 -4
- data/lib/spec/matchers/change.rb +1 -1
- data/lib/spec/matchers/has.rb +1 -11
- data/lib/spec/matchers/operator_matcher.rb +0 -0
- data/lib/spec/matchers/raise_error.rb +53 -30
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraint_matchers.rb +5 -1
- data/lib/spec/mocks/argument_expectation.rb +26 -0
- data/lib/spec/mocks/extensions.rb +1 -0
- data/lib/spec/mocks/framework.rb +15 -0
- data/lib/spec/mocks/message_expectation.rb +29 -5
- data/lib/spec/mocks/mock.rb +9 -7
- data/lib/spec/mocks/proxy.rb +26 -12
- data/lib/spec/rake/spectask.rb +5 -5
- data/lib/spec/runner/backtrace_tweaker.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +2 -3
- data/lib/spec/runner/formatter/base_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +4 -8
- data/lib/spec/runner/formatter/html_formatter.rb +18 -14
- data/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +4 -0
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +5 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +18 -7
- data/lib/spec/runner/option_parser.rb +17 -15
- data/lib/spec/runner/options.rb +37 -14
- data/lib/spec/runner/reporter.rb +15 -11
- data/lib/spec/story/extensions/regexp.rb +2 -2
- data/lib/spec/story/extensions/string.rb +2 -2
- data/lib/spec/story/runner.rb +9 -5
- data/lib/spec/story/runner/plain_text_story_runner.rb +2 -2
- data/lib/spec/story/runner/scenario_runner.rb +8 -0
- data/lib/spec/story/runner/story_mediator.rb +1 -1
- data/lib/spec/story/runner/story_runner.rb +3 -1
- data/lib/spec/story/step.rb +4 -4
- data/lib/spec/story/story.rb +8 -11
- data/lib/spec/story/world.rb +0 -1
- data/lib/spec/version.rb +2 -2
- data/plugins/mock_frameworks/rspec.rb +2 -0
- data/spec/autotest/rspec_spec.rb +12 -10
- data/spec/spec/example/configuration_spec.rb +0 -0
- data/spec/spec/example/example_group/described_module_spec.rb +20 -0
- data/spec/spec/example/example_group/warning_messages_spec.rb +76 -0
- data/spec/spec/example/example_group_factory_spec.rb +117 -102
- data/spec/spec/example/example_group_methods_spec.rb +51 -17
- data/spec/spec/example/example_group_spec.rb +13 -1
- data/spec/spec/example/example_methods_spec.rb +28 -6
- data/spec/spec/example/nested_example_group_spec.rb +12 -0
- data/spec/spec/example/predicate_matcher_spec.rb +0 -0
- data/spec/spec/expectations/differs/default_spec.rb +27 -9
- data/spec/spec/matchers/be_spec.rb +24 -0
- data/spec/spec/matchers/has_spec.rb +16 -0
- data/spec/spec/matchers/raise_error_spec.rb +124 -0
- data/spec/spec/mocks/{bug_report_10263.rb → bug_report_10263_spec.rb} +0 -0
- data/spec/spec/mocks/bug_report_11545_spec.rb +2 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +8 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +32 -0
- data/spec/spec/mocks/mock_spec.rb +56 -37
- data/spec/spec/mocks/partial_mock_spec.rb +41 -5
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +6 -0
- data/spec/spec/runner/execution_context_spec.rb +7 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +3 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +30 -25
- data/spec/spec/runner/formatter/html_formatter_spec.rb +0 -3
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +333 -0
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +12 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +110 -78
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +105 -1
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -28
- data/spec/spec/runner/option_parser_spec.rb +65 -49
- data/spec/spec/runner/options_spec.rb +103 -17
- data/spec/spec/runner/reporter_spec.rb +10 -7
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner/spec_parser_spec.rb +10 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +14 -13
- data/spec/spec/story/runner/scenario_runner_spec.rb +124 -52
- data/spec/spec/story/runner/story_mediator_spec.rb +2 -2
- data/spec/spec/story/runner/story_runner_spec.rb +40 -2
- data/spec/spec/story/runner_spec.rb +59 -72
- data/spec/spec/story/step_spec.rb +20 -1
- data/spec/spec/story/story_spec.rb +2 -2
- data/stories/all.rb +1 -1
- data/stories/example_groups/stories.rb +4 -3
- data/stories/mock_framework_integration/stories.rb +7 -0
- data/stories/mock_framework_integration/use_flexmock.story +9 -0
- data/stories/resources/spec/spec_with_flexmock.rb +18 -0
- metadata +21 -18
- data/pre_commit/lib/pre_commit.rb +0 -4
- data/pre_commit/lib/pre_commit/core.rb +0 -50
- data/pre_commit/lib/pre_commit/pre_commit.rb +0 -54
- data/pre_commit/lib/pre_commit/rspec.rb +0 -111
- data/pre_commit/lib/pre_commit/rspec_on_rails.rb +0 -313
- data/pre_commit/spec/pre_commit/pre_commit_spec.rb +0 -15
- data/pre_commit/spec/pre_commit/rspec_on_rails_spec.rb +0 -36
- data/pre_commit/spec/spec_helper.rb +0 -3
- data/pre_commit/spec/spec_suite.rb +0 -11
File without changes
|
@@ -75,6 +75,14 @@ module Spec
|
|
75
75
|
@mock.msg(37)
|
76
76
|
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (no args) but received it with (37)")
|
77
77
|
end
|
78
|
+
|
79
|
+
it "should fail hash_including with missing key" do
|
80
|
+
lambda do
|
81
|
+
@mock.should_receive(:msg).with(hash_including(:a => 1))
|
82
|
+
@mock.msg({})
|
83
|
+
end.should raise_error(MockExpectationError, "Mock 'test mock' expected :msg with (hash_including(:a=>1)) but received it with ({})")
|
84
|
+
end
|
85
|
+
|
78
86
|
end
|
79
87
|
|
80
88
|
describe "failing deprecated MockArgumentConstraints" do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Mocks
|
5
|
+
describe HashIncludingConstraint do
|
6
|
+
|
7
|
+
it "should match the same hash" do
|
8
|
+
hash_including(:a => 1).matches?(:a => 1).should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not match a non-hash" do
|
12
|
+
hash_including(:a => 1).matches?(1).should_not be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should match a hash with extra stuff" do
|
16
|
+
hash_including(:a => 1).matches?(:a => 1, :b => 2).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not match a hash with a missing key" do
|
20
|
+
hash_including(:a => 1).matches?(:b => 2).should_not be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should not match a hash with an incorrect value" do
|
24
|
+
hash_including(:a => 1, :b => 2).matches?(:a => 1, :b => 3).should_not be_true
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should describe itself properly" do
|
28
|
+
HashIncludingConstraint.new(:a => 1).description.should == "hash_including(:a=>1)"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -37,18 +37,16 @@ module Spec
|
|
37
37
|
|
38
38
|
it "should fail when receiving message specified as not to be received" do
|
39
39
|
@mock.should_not_receive(:not_expected)
|
40
|
-
@mock.not_expected
|
41
40
|
lambda {
|
42
|
-
@mock.
|
41
|
+
@mock.not_expected
|
43
42
|
violated
|
44
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (
|
43
|
+
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
45
44
|
end
|
46
45
|
|
47
46
|
it "should fail when receiving message specified as not to be received with args" do
|
48
47
|
@mock.should_not_receive(:not_expected).with("unexpected text")
|
49
|
-
@mock.not_expected("unexpected text")
|
50
48
|
lambda {
|
51
|
-
@mock.
|
49
|
+
@mock.not_expected("unexpected text")
|
52
50
|
violated
|
53
51
|
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (\"unexpected text\") 0 times, but received it once")
|
54
52
|
end
|
@@ -77,7 +75,7 @@ module Spec
|
|
77
75
|
@mock.rspec_verify
|
78
76
|
end
|
79
77
|
|
80
|
-
it "should raise exception if args
|
78
|
+
it "should raise exception if args don't match when method called" do
|
81
79
|
@mock.should_receive(:something).with("a","b","c").and_return("booh")
|
82
80
|
lambda {
|
83
81
|
@mock.something("a","d","c")
|
@@ -85,6 +83,24 @@ module Spec
|
|
85
83
|
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
|
86
84
|
end
|
87
85
|
|
86
|
+
it "should raise exception if args don't match when method called even when the method is stubbed" do
|
87
|
+
@mock.stub!(:something)
|
88
|
+
@mock.should_receive(:something).with("a","b","c")
|
89
|
+
lambda {
|
90
|
+
@mock.something("a","d","c")
|
91
|
+
@mock.rspec_verify
|
92
|
+
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should raise exception if args don't match when method called even when using null_object" do
|
96
|
+
@mock = mock("test mock", :null_object => true)
|
97
|
+
@mock.should_receive(:something).with("a","b","c")
|
98
|
+
lambda {
|
99
|
+
@mock.something("a","d","c")
|
100
|
+
@mock.rspec_verify
|
101
|
+
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (\"a\", \"b\", \"c\") but received it with (\"a\", \"d\", \"c\")")
|
102
|
+
end
|
103
|
+
|
88
104
|
it "should fail if unexpected method called" do
|
89
105
|
lambda {
|
90
106
|
@mock.something("a","b","c")
|
@@ -110,23 +126,19 @@ module Spec
|
|
110
126
|
end
|
111
127
|
|
112
128
|
it "should fail right away when method defined as never is received" do
|
113
|
-
pending "Used to pass (false positive). Which one is wrong, the spec or the actual behavior?"
|
114
|
-
|
115
129
|
@mock.should_receive(:not_expected).never
|
116
130
|
lambda {
|
117
131
|
@mock.not_expected
|
118
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected 0 times, but received it
|
132
|
+
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
119
133
|
end
|
120
134
|
|
121
135
|
it "should eventually fail when method defined as never is received" do
|
122
136
|
@mock.should_receive(:not_expected).never
|
123
|
-
@mock.not_expected
|
124
|
-
|
125
137
|
lambda {
|
126
|
-
@mock.
|
127
|
-
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (
|
138
|
+
@mock.not_expected
|
139
|
+
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :not_expected with (no args) 0 times, but received it once")
|
128
140
|
end
|
129
|
-
|
141
|
+
|
130
142
|
it "should raise when told to" do
|
131
143
|
@mock.should_receive(:something).and_raise(RuntimeError)
|
132
144
|
lambda do
|
@@ -186,14 +198,20 @@ module Spec
|
|
186
198
|
@mock.something 1
|
187
199
|
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (no args) but received it with (1)")
|
188
200
|
end
|
189
|
-
|
201
|
+
|
190
202
|
it "should fail when args are expected but none are received" do
|
191
203
|
@mock.should_receive(:something).with(1)
|
192
204
|
lambda {
|
193
205
|
@mock.something
|
194
206
|
}.should raise_error(MockExpectationError, "Mock 'test mock' expected :something with (1) but received it with (no args)")
|
195
207
|
end
|
196
|
-
|
208
|
+
|
209
|
+
it "should return value from block by default" do
|
210
|
+
@mock.stub!(:method_that_yields).and_yield
|
211
|
+
@mock.method_that_yields { :returned_obj }.should == :returned_obj
|
212
|
+
@mock.rspec_verify
|
213
|
+
end
|
214
|
+
|
197
215
|
it "should yield 0 args to blocks that take a variable number of arguments" do
|
198
216
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield
|
199
217
|
a = nil
|
@@ -238,7 +256,7 @@ module Spec
|
|
238
256
|
a.should == [99, 27, "go"]
|
239
257
|
@mock.rspec_verify
|
240
258
|
end
|
241
|
-
|
259
|
+
|
242
260
|
it "should yield many args 3 times consecutively to blocks that take a variable number of arguments" do
|
243
261
|
@mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go").
|
244
262
|
and_yield("wait", :amber).
|
@@ -347,7 +365,7 @@ module Spec
|
|
347
365
|
mock.rspec_reset
|
348
366
|
mock.rspec_verify #should throw if reset didn't work
|
349
367
|
end
|
350
|
-
|
368
|
+
|
351
369
|
it "should work even after method_missing starts raising NameErrors instead of NoMethodErrors" do
|
352
370
|
# Object#method_missing throws either NameErrors or NoMethodErrors.
|
353
371
|
#
|
@@ -376,7 +394,7 @@ module Spec
|
|
376
394
|
lambda { @mock.foobar }.should_not raise_error(NameError)
|
377
395
|
lambda { @mock.foobar }.should raise_error(MockExpectationError)
|
378
396
|
end
|
379
|
-
|
397
|
+
|
380
398
|
it "should temporarily replace a method stub on a mock" do
|
381
399
|
@mock.stub!(:msg).and_return(:stub_value)
|
382
400
|
@mock.should_receive(:msg).with(:arg).and_return(:mock_value)
|
@@ -385,7 +403,7 @@ module Spec
|
|
385
403
|
@mock.msg.should equal(:stub_value)
|
386
404
|
@mock.rspec_verify
|
387
405
|
end
|
388
|
-
|
406
|
+
|
389
407
|
it "should temporarily replace a method stub on a non-mock" do
|
390
408
|
non_mock = Object.new
|
391
409
|
non_mock.stub!(:msg).and_return(:stub_value)
|
@@ -400,8 +418,9 @@ module Spec
|
|
400
418
|
mock = Mock.new('name', :message => :response)
|
401
419
|
mock.message.should == :response
|
402
420
|
end
|
421
|
+
|
403
422
|
end
|
404
|
-
|
423
|
+
|
405
424
|
describe "a mock message receiving a block" do
|
406
425
|
before(:each) do
|
407
426
|
@mock = mock("mock")
|
@@ -414,60 +433,60 @@ module Spec
|
|
414
433
|
|
415
434
|
it "should call the block after #should_receive" do
|
416
435
|
@mock.should_receive(:foo) { add_call }
|
417
|
-
|
436
|
+
|
418
437
|
@mock.foo
|
419
|
-
|
438
|
+
|
420
439
|
@calls.should == 1
|
421
440
|
end
|
422
|
-
|
441
|
+
|
423
442
|
it "should call the block after #once" do
|
424
443
|
@mock.should_receive(:foo).once { add_call }
|
425
|
-
|
444
|
+
|
426
445
|
@mock.foo
|
427
|
-
|
446
|
+
|
428
447
|
@calls.should == 1
|
429
448
|
end
|
430
|
-
|
449
|
+
|
431
450
|
it "should call the block after #twice" do
|
432
451
|
@mock.should_receive(:foo).twice { add_call }
|
433
|
-
|
452
|
+
|
434
453
|
@mock.foo
|
435
454
|
@mock.foo
|
436
|
-
|
455
|
+
|
437
456
|
@calls.should == 2
|
438
457
|
end
|
439
|
-
|
458
|
+
|
440
459
|
it "should call the block after #times" do
|
441
460
|
@mock.should_receive(:foo).exactly(10).times { add_call }
|
442
461
|
|
443
462
|
(1..10).each { @mock.foo }
|
444
|
-
|
463
|
+
|
445
464
|
@calls.should == 10
|
446
465
|
end
|
447
|
-
|
466
|
+
|
448
467
|
it "should call the block after #any_number_of_times" do
|
449
468
|
@mock.should_receive(:foo).any_number_of_times { add_call }
|
450
469
|
|
451
470
|
(1..7).each { @mock.foo }
|
452
|
-
|
471
|
+
|
453
472
|
@calls.should == 7
|
454
473
|
end
|
455
|
-
|
474
|
+
|
456
475
|
it "should call the block after #with" do
|
457
476
|
@mock.should_receive(:foo).with(:arg) { add_call }
|
458
477
|
|
459
478
|
@mock.foo(:arg)
|
460
|
-
|
479
|
+
|
461
480
|
@calls.should == 1
|
462
481
|
end
|
463
|
-
|
482
|
+
|
464
483
|
it "should call the block after #ordered" do
|
465
484
|
@mock.should_receive(:foo).ordered { add_call }
|
466
485
|
@mock.should_receive(:bar).ordered { add_call }
|
467
486
|
|
468
487
|
@mock.foo
|
469
488
|
@mock.bar
|
470
|
-
|
489
|
+
|
471
490
|
@calls.should == 2
|
472
491
|
end
|
473
492
|
end
|
@@ -21,11 +21,11 @@ module Spec
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should_not_receive should mock out the method" do
|
24
|
+
pending("example raises the expected error, yet fails")
|
24
25
|
@object.should_not_receive(:fuhbar)
|
25
|
-
@object.fuhbar
|
26
26
|
lambda do
|
27
|
-
@object.
|
28
|
-
end.should raise_error(
|
27
|
+
@object.fuhbar
|
28
|
+
end.should raise_error(MockExpectationError, "Mock 'Object' expected :fuhbar with (no args) 0 times, but received it once")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should_not_receive should return a negative message expectation" do
|
@@ -66,10 +66,10 @@ module Spec
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should_not_receive should also take a String argument" do
|
69
|
+
pending("example raises the expected error, yet fails")
|
69
70
|
@object.should_not_receive('foobar')
|
70
|
-
@object.foobar
|
71
71
|
lambda do
|
72
|
-
@object.
|
72
|
+
@object.foobar
|
73
73
|
end.should raise_error(Spec::Mocks::MockExpectationError)
|
74
74
|
end
|
75
75
|
|
@@ -102,5 +102,41 @@ module Spec
|
|
102
102
|
lambda { o.stub!(:bar) }.should_not raise_error(NoMethodError)
|
103
103
|
end
|
104
104
|
end
|
105
|
+
|
106
|
+
describe "Method visibility when using partial mocks" do
|
107
|
+
class MockableClass
|
108
|
+
def public_method
|
109
|
+
private_method
|
110
|
+
protected_method
|
111
|
+
end
|
112
|
+
protected
|
113
|
+
def protected_method; end
|
114
|
+
private
|
115
|
+
def private_method; end
|
116
|
+
end
|
117
|
+
|
118
|
+
before(:each) do
|
119
|
+
@object = MockableClass.new
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should keep public methods public' do
|
123
|
+
@object.should_receive(:public_method)
|
124
|
+
@object.public_methods.should include('public_method')
|
125
|
+
@object.public_method
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should keep private methods private' do
|
129
|
+
@object.should_receive(:private_method)
|
130
|
+
@object.private_methods.should include('private_method')
|
131
|
+
@object.public_method
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should keep protected methods protected' do
|
135
|
+
@object.should_receive(:protected_method)
|
136
|
+
@object.protected_methods.should include('protected_method')
|
137
|
+
@object.public_method
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
105
141
|
end
|
106
142
|
end
|
@@ -109,6 +109,12 @@ module Spec
|
|
109
109
|
@mock.should_receive(:random_call).with(no_args)
|
110
110
|
@mock.random_call()
|
111
111
|
end
|
112
|
+
|
113
|
+
it "should match hash with hash_including same hash" do
|
114
|
+
@mock.should_receive(:random_call).with(hash_including(:a => 1))
|
115
|
+
@mock.random_call(:a => 1)
|
116
|
+
end
|
117
|
+
|
112
118
|
end
|
113
119
|
|
114
120
|
describe Methods, "handling non-constraint arguments" do
|
@@ -7,7 +7,13 @@ describe "ExecutionContext" do
|
|
7
7
|
dt.should be_an_instance_of(Spec::Mocks::DuckTypeArgConstraint)
|
8
8
|
dt.matches?([]).should be_true
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
it "should provide hash_including" do
|
12
|
+
hi = hash_including(:a => 1)
|
13
|
+
hi.should be_an_instance_of(Spec::Mocks::HashIncludingConstraint)
|
14
|
+
hi.matches?(:a => 1).should be_true
|
15
|
+
end
|
16
|
+
|
11
17
|
it "should violate when violated()" do
|
12
18
|
lambda do
|
13
19
|
violated
|
@@ -20,9 +20,10 @@ module Spec
|
|
20
20
|
formatter.add_example_group(Class.new(ExampleGroup).describe("b 2"))
|
21
21
|
formatter.example_failed("e 2", nil, Reporter::Failure.new(nil, RuntimeError.new))
|
22
22
|
formatter.example_failed("e 3", nil, Reporter::Failure.new(nil, RuntimeError.new))
|
23
|
-
io.string.should
|
23
|
+
io.string.should include("b 1")
|
24
|
+
io.string.should include("b 2")
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
it "should delimit ExampleGroup superclass descriptions with :" do
|
27
28
|
parent_example_group = Class.new(example_group).describe("Parent")
|
28
29
|
child_example_group = Class.new(parent_example_group).describe("#child_method")
|
@@ -189,9 +189,9 @@ a {
|
|
189
189
|
<div class="failure" id="failure_1">
|
190
190
|
<div class="message"><pre>Mock 'poke me' expected :poke with (any args) once, but received it 0 times</pre></div>
|
191
191
|
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:13:
|
192
|
-
|
193
|
-
|
194
|
-
|
192
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
193
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
194
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
195
195
|
<pre class="ruby"><code><span class="linenum">11</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">should fail when expected message not received</span><span class="punct">"</span> <span class="keyword">do</span>
|
196
196
|
<span class="linenum">12</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">poke me</span><span class="punct">")</span>
|
197
197
|
<span class="offending"><span class="linenum">13</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:poke</span><span class="punct">)</span></span>
|
@@ -205,9 +205,9 @@ a {
|
|
205
205
|
<div class="failure" id="failure_2">
|
206
206
|
<div class="message"><pre>Mock 'one two three' received :three out of order</pre></div>
|
207
207
|
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:22:
|
208
|
-
|
209
|
-
|
210
|
-
|
208
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
209
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
210
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
211
211
|
<pre class="ruby"><code><span class="linenum">20</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_receive</span><span class="punct">(</span><span class="symbol">:three</span><span class="punct">).</span><span class="ident">ordered</span>
|
212
212
|
<span class="linenum">21</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">one</span>
|
213
213
|
<span class="offending"><span class="linenum">22</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">three</span></span>
|
@@ -219,15 +219,14 @@ a {
|
|
219
219
|
<dd class="spec failed">
|
220
220
|
<span class="failed_spec_name">should get yelled at when sending unexpected messages</span>
|
221
221
|
<div class="failure" id="failure_3">
|
222
|
-
<div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (
|
223
|
-
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<pre class="ruby"><code><span class="linenum">
|
228
|
-
<span class="linenum">
|
229
|
-
<span class="offending"><span class="linenum">
|
230
|
-
<span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span>
|
222
|
+
<div class="message"><pre>Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once</pre></div>
|
223
|
+
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:29:
|
224
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
225
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
226
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
227
|
+
<pre class="ruby"><code><span class="linenum">27</span> <span class="ident">mock</span> <span class="punct">=</span> <span class="ident">mock</span><span class="punct">("</span><span class="string">don't talk to me</span><span class="punct">")</span>
|
228
|
+
<span class="linenum">28</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">should_not_receive</span><span class="punct">(</span><span class="symbol">:any_message_at_all</span><span class="punct">)</span>
|
229
|
+
<span class="offending"><span class="linenum">29</span> <span class="ident">mock</span><span class="punct">.</span><span class="ident">any_message_at_all</span></span>
|
231
230
|
<span class="linenum">30</span> <span class="keyword">end</span></code></pre>
|
232
231
|
</div>
|
233
232
|
</dd>
|
@@ -236,7 +235,10 @@ a {
|
|
236
235
|
<span class="failed_spec_name">has a bug we need to fix</span>
|
237
236
|
<div class="failure" id="failure_4">
|
238
237
|
<div class="message"><pre>Expected pending 'here is the bug' to fail. No Error was raised.</pre></div>
|
239
|
-
|
238
|
+
<div class="backtrace"><pre>./failing_examples/mocking_example.rb:33:
|
239
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
240
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
241
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
240
242
|
<pre class="ruby"><code><span class="linenum">31</span>
|
241
243
|
<span class="linenum">32</span> <span class="ident">it</span> <span class="punct">"</span><span class="string">has a bug we need to fix</span><span class="punct">"</span> <span class="keyword">do</span>
|
242
244
|
<span class="offending"><span class="linenum">33</span> <span class="ident">pending</span> <span class="punct">"</span><span class="string">here is the bug</span><span class="punct">"</span> <span class="keyword">do</span></span>
|
@@ -259,11 +261,14 @@ a {
|
|
259
261
|
Diff:
|
260
262
|
@@ -1,4 +1,4 @@
|
261
263
|
RSpec is a
|
262
|
-
-
|
263
|
-
+
|
264
|
+
-behaviour driven development
|
265
|
+
+behavior driven development
|
264
266
|
framework for Ruby
|
265
267
|
</pre></div>
|
266
|
-
|
268
|
+
<div class="backtrace"><pre>./failing_examples/diffing_spec.rb:13:
|
269
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
270
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
271
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
267
272
|
<pre class="ruby"><code><span class="linenum">11</span><span class="ident">framework</span> <span class="keyword">for</span> <span class="constant">Ruby</span>
|
268
273
|
<span class="linenum">12</span><span class="constant">EOF</span>
|
269
274
|
<span class="offending"><span class="linenum">13</span> <span class="ident">usa</span><span class="punct">.</span><span class="ident">should</span> <span class="punct">==</span> <span class="ident">uk</span></span>
|
@@ -287,14 +292,14 @@ Diff:
|
|
287
292
|
@@ -1,5 +1,5 @@
|
288
293
|
<Animal
|
289
294
|
name=bob,
|
290
|
-
-species=
|
291
|
-
+species=
|
295
|
+
-species=tortoise
|
296
|
+
+species=giraffe
|
292
297
|
>
|
293
298
|
</pre></div>
|
294
|
-
<div class="backtrace"><pre>./failing_examples/
|
295
|
-
|
296
|
-
|
297
|
-
|
299
|
+
<div class="backtrace"><pre>./failing_examples/diffing_spec.rb:34:
|
300
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:25:
|
301
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:in `chdir'
|
302
|
+
/Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/html_formatter_spec.rb:21:</pre></div>
|
298
303
|
<pre class="ruby"><code><span class="linenum">32</span> <span class="ident">expected</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">giraffe</span><span class="punct">"</span>
|
299
304
|
<span class="linenum">33</span> <span class="ident">actual</span> <span class="punct">=</span> <span class="constant">Animal</span><span class="punct">.</span><span class="ident">new</span> <span class="punct">"</span><span class="string">bob</span><span class="punct">",</span> <span class="punct">"</span><span class="string">tortoise</span><span class="punct">"</span>
|
300
305
|
<span class="offending"><span class="linenum">34</span> <span class="ident">expected</span><span class="punct">.</span><span class="ident">should</span> <span class="ident">eql</span><span class="punct">(</span><span class="ident">actual</span><span class="punct">)</span></span>
|