rspec 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +78 -1
- data/EXAMPLES.rd +8 -5
- data/README +1 -0
- data/Rakefile +1 -1
- data/examples/pending_example.rb +20 -0
- data/lib/autotest/rspec.rb +46 -18
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/dsl/behaviour.rb +37 -27
- data/lib/spec/dsl/behaviour_callbacks.rb +4 -0
- data/lib/spec/dsl/behaviour_eval.rb +27 -16
- data/lib/spec/dsl/behaviour_factory.rb +2 -2
- data/lib/spec/dsl/composite_proc_builder.rb +9 -4
- data/lib/spec/dsl/configuration.rb +20 -4
- data/lib/spec/dsl/description.rb +7 -0
- data/lib/spec/dsl/errors.rb +9 -0
- data/lib/spec/dsl/example.rb +18 -10
- data/lib/spec/matchers/have.rb +10 -13
- data/lib/spec/matchers/operator_matcher.rb +3 -3
- data/lib/spec/matchers/raise_error.rb +8 -3
- data/lib/spec/mocks/error_generator.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +11 -0
- data/lib/spec/mocks/methods.rb +9 -5
- data/lib/spec/mocks/proxy.rb +13 -9
- data/lib/spec/rake/spectask.rb +80 -38
- data/lib/spec/runner/backtrace_tweaker.rb +2 -1
- data/lib/spec/runner/behaviour_runner.rb +37 -16
- data/lib/spec/runner/formatter/base_formatter.rb +23 -15
- data/lib/spec/runner/formatter/base_text_formatter.rb +39 -11
- data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +7 -3
- data/lib/spec/runner/formatter/failing_examples_formatter.rb +3 -3
- data/lib/spec/runner/formatter/html_formatter.rb +32 -25
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -5
- data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
- data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
- data/lib/spec/runner/option_parser.rb +6 -5
- data/lib/spec/runner/options.rb +60 -43
- data/lib/spec/runner/reporter.rb +17 -6
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/translator.rb +8 -0
- data/lib/spec/version.rb +3 -3
- data/plugins/mock_frameworks/flexmock.rb +14 -18
- data/plugins/mock_frameworks/mocha.rb +0 -2
- data/plugins/mock_frameworks/rr.rb +21 -0
- data/spec/autotest/discover_spec.rb +19 -0
- data/spec/autotest/rspec_spec.rb +257 -0
- data/spec/autotest_helper.rb +4 -0
- data/spec/spec/dsl/behaviour_eval_spec.rb +30 -0
- data/spec/spec/dsl/behaviour_factory_spec.rb +18 -0
- data/spec/spec/dsl/behaviour_spec.rb +95 -58
- data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -13
- data/spec/spec/dsl/configuration_spec.rb +6 -1
- data/spec/spec/dsl/description_spec.rb +9 -1
- data/spec/spec/dsl/example_class_spec.rb +3 -3
- data/spec/spec/dsl/example_instance_spec.rb +26 -28
- data/spec/spec/dsl/example_matcher_spec.rb +91 -0
- data/spec/spec/dsl/shared_behaviour_spec.rb +24 -0
- data/spec/spec/expectations/extensions/object_spec.rb +2 -2
- data/spec/spec/expectations/fail_with_spec.rb +2 -2
- data/spec/spec/matchers/have_spec.rb +1 -1
- data/spec/spec/matchers/operator_matcher_spec.rb +10 -10
- data/spec/spec/matchers/raise_error_spec.rb +38 -0
- data/spec/spec/mocks/argument_expectation_spec.rb +18 -14
- data/spec/spec/mocks/at_most_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_11545_spec.rb +31 -0
- data/spec/spec/mocks/partial_mock_spec.rb +33 -1
- data/spec/spec/runner/behaviour_runner_spec.rb +72 -49
- data/spec/spec/runner/command_line_spec.rb +1 -1
- data/spec/spec/runner/context_matching_spec.rb +10 -10
- data/spec/spec/runner/drb_command_line_spec.rb +62 -59
- data/spec/spec/runner/extensions/bug_report_10577_spec.rb +35 -0
- data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +15 -2
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/html_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +14 -15
- data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +42 -9
- data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +40 -40
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +55 -49
- data/spec/spec/runner/option_parser_spec.rb +16 -15
- data/spec/spec/runner/options_spec.rb +64 -31
- data/spec/spec/runner/reporter_spec.rb +67 -15
- data/spec/spec/spec_classes.rb +9 -1
- data/spec/spec/translator_spec.rb +48 -0
- data/spec/spec_helper.rb +5 -2
- metadata +13 -6
- data/examples/not_yet_implemented_spec.rb +0 -12
- data/spec/spec/runner/example_matcher_spec.rb +0 -127
@@ -22,19 +22,6 @@ module Spec
|
|
22
22
|
@builder.proc.call.should == [:proc1, :proc2]
|
23
23
|
end
|
24
24
|
|
25
|
-
it "calls block on exceptions" do
|
26
|
-
exception1 = Exception.new("Proc1 Error")
|
27
|
-
exception2 = Exception.new("Proc2 Error")
|
28
|
-
@builder << proc {raise exception1}
|
29
|
-
@builder << proc {raise exception2}
|
30
|
-
@builder << proc {:successful}
|
31
|
-
|
32
|
-
errors = []
|
33
|
-
@builder.proc {|e| errors << e }.call.should == [exception1, exception2, :successful]
|
34
|
-
|
35
|
-
errors.should == [exception1, exception2]
|
36
|
-
end
|
37
|
-
|
38
25
|
it "evals procs in the caller's instance" do
|
39
26
|
the_proc = proc do
|
40
27
|
@an_attribute = :the_value
|
@@ -26,6 +26,11 @@ module Spec
|
|
26
26
|
@config.mock_with(:flexmock)
|
27
27
|
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/flexmock$/
|
28
28
|
end
|
29
|
+
|
30
|
+
it "should let you set rr" do
|
31
|
+
@config.mock_with(:rr)
|
32
|
+
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rr$/
|
33
|
+
end
|
29
34
|
|
30
35
|
it "should let you set an arbitrary adapter module" do
|
31
36
|
adapter = Module.new
|
@@ -36,7 +41,7 @@ module Spec
|
|
36
41
|
it "should let you define modules to be included" do
|
37
42
|
mod = Module.new
|
38
43
|
@config.include mod
|
39
|
-
@config.
|
44
|
+
@config.modules_for(nil).should include(mod)
|
40
45
|
end
|
41
46
|
|
42
47
|
[:prepend_before, :append_before, :prepend_after, :append_after].each do |m|
|
@@ -72,10 +72,18 @@ module Spec
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
describe Description, " constructed with options" do
|
75
|
+
describe Description, " constructed with options" do
|
76
|
+
before(:each) do
|
77
|
+
@description = Description.new(Behaviour, :a => "b", :spec_path => "blah")
|
78
|
+
end
|
79
|
+
|
76
80
|
it "should provide its options" do
|
77
81
|
@description[:a].should == "b"
|
78
82
|
end
|
83
|
+
|
84
|
+
it "should wrap spec path using File.expand_path" do
|
85
|
+
@description[:spec_path].should == File.expand_path("blah")
|
86
|
+
end
|
79
87
|
end
|
80
88
|
end
|
81
89
|
end
|
@@ -15,9 +15,9 @@ module Spec
|
|
15
15
|
|
16
16
|
it "should report errors in example" do
|
17
17
|
error = Exception.new
|
18
|
-
@
|
19
|
-
|
20
|
-
run(
|
18
|
+
example = @example_class.new("example") {raise(error)}
|
19
|
+
@reporter.should_receive(:example_finished).with(equal(example), error, "example", false)
|
20
|
+
run(example)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -3,31 +3,27 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
3
3
|
module Spec
|
4
4
|
module DSL
|
5
5
|
describe Example, " instance" do
|
6
|
-
|
7
|
-
# predicate_matchers :is_a
|
8
|
-
def is_a(error)
|
9
|
-
be_is_a(error)
|
10
|
-
end
|
6
|
+
predicate_matchers[:is_a] = [:is_a?]
|
11
7
|
|
12
|
-
before do
|
8
|
+
before(:each) do
|
13
9
|
@reporter = stub("reporter", :example_started => nil, :example_finished => nil)
|
14
10
|
end
|
15
11
|
|
16
12
|
it "should send reporter example_started" do
|
17
13
|
example=Example.new("example") {}
|
18
|
-
@reporter.should_receive(:example_started).with(
|
14
|
+
@reporter.should_receive(:example_started).with(equal(example))
|
19
15
|
example.run(@reporter, nil, nil, false, nil)
|
20
16
|
end
|
21
17
|
|
22
18
|
it "should report its name for dry run" do
|
23
19
|
example=Example.new("example") {}
|
24
|
-
@reporter.should_receive(:example_finished).with(
|
20
|
+
@reporter.should_receive(:example_finished).with(equal(example))
|
25
21
|
example.run(@reporter, nil, nil, true, nil) #4th arg indicates dry run
|
26
22
|
end
|
27
23
|
|
28
24
|
it "should report success" do
|
29
25
|
example=Example.new("example") {}
|
30
|
-
@reporter.should_receive(:example_finished).with(
|
26
|
+
@reporter.should_receive(:example_finished).with(equal(example), nil, nil, false)
|
31
27
|
example.run(@reporter, nil, nil, nil, nil)
|
32
28
|
end
|
33
29
|
|
@@ -35,16 +31,16 @@ module Spec
|
|
35
31
|
example=Example.new("example") do
|
36
32
|
(2+2).should == 5
|
37
33
|
end
|
38
|
-
@reporter.should_receive(:example_finished).with(
|
34
|
+
@reporter.should_receive(:example_finished).with(equal(example), is_a(Spec::Expectations::ExpectationNotMetError), "example", false)
|
39
35
|
example.run(@reporter, nil, nil, nil, nil)
|
40
36
|
end
|
41
37
|
|
42
38
|
it "should report failure due to error" do
|
43
|
-
error=
|
39
|
+
error=NonStandardError.new
|
44
40
|
example=Example.new("example") do
|
45
41
|
raise(error)
|
46
42
|
end
|
47
|
-
@reporter.should_receive(:example_finished).with(
|
43
|
+
@reporter.should_receive(:example_finished).with(equal(example), error, "example", false)
|
48
44
|
example.run(@reporter, nil, nil, nil, nil)
|
49
45
|
end
|
50
46
|
|
@@ -54,14 +50,14 @@ module Spec
|
|
54
50
|
self.instance_of?(Example).should == false
|
55
51
|
self.instance_of?(scope_class).should == true
|
56
52
|
end
|
57
|
-
@reporter.should_receive(:example_finished).with(
|
53
|
+
@reporter.should_receive(:example_finished).with(equal(example), nil, nil, false)
|
58
54
|
example.run(@reporter, nil, nil, nil, scope_class.new)
|
59
55
|
end
|
60
56
|
|
61
57
|
it "should not run example block if before_each fails" do
|
62
58
|
example_ran = false
|
63
59
|
example=Example.new("should pass") {example_ran = true}
|
64
|
-
before_each = lambda {raise
|
60
|
+
before_each = lambda {raise NonStandardError}
|
65
61
|
example.run(@reporter, before_each, nil, nil, Object.new)
|
66
62
|
example_ran.should == false
|
67
63
|
end
|
@@ -69,7 +65,7 @@ module Spec
|
|
69
65
|
it "should run after_each block if before_each fails" do
|
70
66
|
after_each_ran = false
|
71
67
|
example=Example.new("should pass") {}
|
72
|
-
before_each = lambda {raise
|
68
|
+
before_each = lambda {raise NonStandardError}
|
73
69
|
after_each = lambda {after_each_ran = true}
|
74
70
|
example.run(@reporter, before_each, after_each, nil, Object.new)
|
75
71
|
after_each_ran.should == true
|
@@ -77,13 +73,13 @@ module Spec
|
|
77
73
|
|
78
74
|
it "should run after_each block when example fails" do
|
79
75
|
example=Example.new("example") do
|
80
|
-
raise("in body")
|
76
|
+
raise(NonStandardError.new("in body"))
|
81
77
|
end
|
82
78
|
after_each=lambda do
|
83
79
|
raise("in after_each")
|
84
80
|
end
|
85
81
|
@reporter.should_receive(:example_finished) do |example, error, location|
|
86
|
-
example.should
|
82
|
+
example.should equal(example)
|
87
83
|
location.should eql("example")
|
88
84
|
error.message.should eql("in body")
|
89
85
|
end
|
@@ -92,9 +88,9 @@ module Spec
|
|
92
88
|
|
93
89
|
it "should report failure location when in before_each" do
|
94
90
|
example=Example.new("example") {}
|
95
|
-
before_each=lambda { raise("in before_each") }
|
91
|
+
before_each=lambda { raise(NonStandardError.new("in before_each")) }
|
96
92
|
@reporter.should_receive(:example_finished) do |name, error, location|
|
97
|
-
name.should
|
93
|
+
name.should equal(example)
|
98
94
|
error.message.should eql("in before_each")
|
99
95
|
location.should eql("before(:each)")
|
100
96
|
end
|
@@ -103,9 +99,9 @@ module Spec
|
|
103
99
|
|
104
100
|
it "should report failure location when in after_each" do
|
105
101
|
example = Example.new("example") {}
|
106
|
-
after_each = lambda { raise("in after_each") }
|
102
|
+
after_each = lambda { raise(NonStandardError.new("in after_each")) }
|
107
103
|
@reporter.should_receive(:example_finished) do |name, error, location|
|
108
|
-
name.should
|
104
|
+
name.should equal(example)
|
109
105
|
error.message.should eql("in after_each")
|
110
106
|
location.should eql("after(:each)")
|
111
107
|
end
|
@@ -120,16 +116,16 @@ module Spec
|
|
120
116
|
example = Example.new(:__generate_description) {
|
121
117
|
5.should == 5
|
122
118
|
}
|
123
|
-
@reporter.should_receive(:example_finished) do |
|
124
|
-
|
119
|
+
@reporter.should_receive(:example_finished) do |example, error, location|
|
120
|
+
example.description.should == "NO NAME (Because of --dry-run)"
|
125
121
|
end
|
126
122
|
example.run(@reporter, lambda{}, lambda{}, true, Object.new)
|
127
123
|
end
|
128
124
|
|
129
125
|
it "should report NO NAME when told to use generated description with no expectations" do
|
130
126
|
example = Example.new(:__generate_description) {}
|
131
|
-
@reporter.should_receive(:example_finished) do |
|
132
|
-
|
127
|
+
@reporter.should_receive(:example_finished) do |example, error, location|
|
128
|
+
example.description.should == "NO NAME (Because there were no expectations)"
|
133
129
|
end
|
134
130
|
example.run(@reporter, lambda{}, lambda{}, false, Object.new)
|
135
131
|
end
|
@@ -138,8 +134,8 @@ module Spec
|
|
138
134
|
example = Example.new(:__generate_description) do
|
139
135
|
5.should "" # Has no matches? method..
|
140
136
|
end
|
141
|
-
@reporter.should_receive(:example_finished) do |
|
142
|
-
|
137
|
+
@reporter.should_receive(:example_finished) do |example, error, location|
|
138
|
+
example.description.should == "NO NAME (Because of Error raised in matcher)"
|
143
139
|
end
|
144
140
|
example.run(@reporter, nil, nil, nil, Object.new)
|
145
141
|
end
|
@@ -148,7 +144,9 @@ module Spec
|
|
148
144
|
example = Example.new(:__generate_description) {
|
149
145
|
5.should == 5
|
150
146
|
}
|
151
|
-
@reporter.should_receive(:example_finished)
|
147
|
+
@reporter.should_receive(:example_finished) do |example, error, location|
|
148
|
+
example.description.should == "should == 5"
|
149
|
+
end
|
152
150
|
example.run(@reporter, nil, nil, nil, Object.new)
|
153
151
|
end
|
154
152
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module DSL
|
5
|
+
module ExampleMatcherSpecHelper
|
6
|
+
class MatchDescription
|
7
|
+
def initialize(description)
|
8
|
+
@description = description
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches?(matcher)
|
12
|
+
matcher.matches?(@description)
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure_message
|
16
|
+
"expected matcher.matches?(#{@description.inspect}) to return true, got false"
|
17
|
+
end
|
18
|
+
|
19
|
+
def negative_failure_message
|
20
|
+
"expected matcher.matches?(#{@description.inspect}) to return false, got true"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
def match_description(description)
|
24
|
+
MatchDescription.new(description)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ExampleMatcher do
|
29
|
+
include ExampleMatcherSpecHelper
|
30
|
+
|
31
|
+
it "should match correct behaviour and example" do
|
32
|
+
matcher = ExampleMatcher.new("behaviour", "example")
|
33
|
+
matcher.should match_description("behaviour example")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not match wrong example" do
|
37
|
+
matcher = ExampleMatcher.new("behaviour", "other example")
|
38
|
+
matcher.should_not match_description("behaviour example")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not match wrong behaviour" do
|
42
|
+
matcher = ExampleMatcher.new("other behaviour", "example")
|
43
|
+
matcher.should_not match_description("behaviour example")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should match example only" do
|
47
|
+
matcher = ExampleMatcher.new("behaviour", "example")
|
48
|
+
matcher.should match_description("example")
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should match behaviour only" do
|
52
|
+
matcher = ExampleMatcher.new("behaviour", "example")
|
53
|
+
matcher.should match_description("behaviour")
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should escape regexp chars" do
|
57
|
+
matcher = ExampleMatcher.new("(con|text)", "[example]")
|
58
|
+
matcher.should_not match_description("con p")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should match when behaviour is modularized" do
|
62
|
+
matcher = ExampleMatcher.new("MyModule::MyClass", "example")
|
63
|
+
matcher.should match_description("MyClass example")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe ExampleMatcher, "normal case" do
|
68
|
+
it "matches when passed in example matches" do
|
69
|
+
matcher = ExampleMatcher.new("Foo", "bar")
|
70
|
+
matcher.matches?(["no match", "Foo bar"]).should == true
|
71
|
+
end
|
72
|
+
|
73
|
+
it "does not match when no passed in examples match" do
|
74
|
+
matcher = ExampleMatcher.new("Foo", "bar")
|
75
|
+
matcher.matches?(["no match1", "no match2"]).should == false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ExampleMatcher, "where description has '::' in it" do
|
80
|
+
it "matches when passed in example matches" do
|
81
|
+
matcher = ExampleMatcher.new("Foo::Bar", "baz")
|
82
|
+
matcher.matches?(["no match", "Foo::Bar baz"]).should == true
|
83
|
+
end
|
84
|
+
|
85
|
+
it "does not match when no passed in examples match" do
|
86
|
+
matcher = ExampleMatcher.new("Foo::Bar", "baz")
|
87
|
+
matcher.matches?(["no match1", "no match2"]).should == false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -96,6 +96,30 @@ module Spec
|
|
96
96
|
end
|
97
97
|
end.should_not raise_error(ArgumentError)
|
98
98
|
end
|
99
|
+
|
100
|
+
it "should NOT complain when adding the same shared behaviour in same file with different absolute path" do
|
101
|
+
shared_behaviour_1 = behaviour_class.new("shared behaviour", :shared => true) {}
|
102
|
+
shared_behaviour_2 = behaviour_class.new("shared behaviour", :shared => true) {}
|
103
|
+
|
104
|
+
shared_behaviour_1.description[:spec_path] = "/my/spec/a/../shared.rb"
|
105
|
+
shared_behaviour_2.description[:spec_path] = "/my/spec/b/../shared.rb"
|
106
|
+
|
107
|
+
behaviour_class.add_shared_behaviour(shared_behaviour_1)
|
108
|
+
behaviour_class.add_shared_behaviour(shared_behaviour_2)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should complain when adding a different shared behaviour with the same name in a different file with the same basename" do
|
112
|
+
shared_behaviour_1 = behaviour_class.new("shared behaviour", :shared => true) {}
|
113
|
+
shared_behaviour_2 = behaviour_class.new("shared behaviour", :shared => true) {}
|
114
|
+
|
115
|
+
shared_behaviour_1.description[:spec_path] = "/my/spec/a/shared.rb"
|
116
|
+
shared_behaviour_2.description[:spec_path] = "/my/spec/b/shared.rb"
|
117
|
+
|
118
|
+
behaviour_class.add_shared_behaviour(shared_behaviour_1)
|
119
|
+
lambda do
|
120
|
+
behaviour_class.add_shared_behaviour(shared_behaviour_2)
|
121
|
+
end.should raise_error(ArgumentError, /already exists/)
|
122
|
+
end
|
99
123
|
|
100
124
|
it "should add examples to current behaviour when calling it_should_behave_like" do
|
101
125
|
shared_behaviour = make_shared_behaviour("shared behaviour") {}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../../spec_helper.rb'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe Object, "#should" do
|
4
4
|
before(:each) do
|
5
5
|
@target = "target"
|
6
6
|
@matcher = mock("matcher")
|
@@ -23,7 +23,7 @@ describe "Object#should" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe "
|
26
|
+
describe Object, "#should_not" do
|
27
27
|
before(:each) do
|
28
28
|
@target = "target"
|
29
29
|
@matcher = mock("matcher")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Spec::Expectations, "#fail_with with no diff" do
|
4
4
|
before(:each) do
|
5
5
|
@old_differ = Spec::Expectations.differ
|
6
6
|
Spec::Expectations.differ = nil
|
@@ -23,7 +23,7 @@ describe "Spec::Expectations.fail_with with no diff" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe Spec::Expectations, "#fail_with with diff" do
|
27
27
|
before(:each) do
|
28
28
|
@old_differ = Spec::Expectations.differ
|
29
29
|
@differ = mock("differ")
|
@@ -56,7 +56,7 @@ describe "should have(n).items where result responds to items but returns someth
|
|
56
56
|
end.new
|
57
57
|
lambda do
|
58
58
|
owner.should have(3).items
|
59
|
-
end.should raise_error(
|
59
|
+
end.should raise_error("expected items to be a collection but it does not respond to #length or #size")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -12,7 +12,7 @@ describe "should ==" do
|
|
12
12
|
|
13
13
|
it "should fail when target.==(actual) returns false" do
|
14
14
|
subject = "apple"
|
15
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected "orange"
|
15
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple")
|
16
16
|
subject.should == "orange"
|
17
17
|
end
|
18
18
|
|
@@ -28,7 +28,7 @@ describe "should_not ==" do
|
|
28
28
|
|
29
29
|
it "should fail when target.==(actual) returns false" do
|
30
30
|
subject = "apple"
|
31
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected not == "apple"
|
31
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple")
|
32
32
|
subject.should_not == "apple"
|
33
33
|
end
|
34
34
|
|
@@ -45,7 +45,7 @@ describe "should ===" do
|
|
45
45
|
it "should fail when target.===(actual) returns false" do
|
46
46
|
subject = "apple"
|
47
47
|
subject.should_receive(:===).with("orange").and_return(false)
|
48
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected "orange"
|
48
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple")
|
49
49
|
subject.should === "orange"
|
50
50
|
end
|
51
51
|
|
@@ -62,7 +62,7 @@ describe "should_not ===" do
|
|
62
62
|
it "should fail when target.===(actual) returns false" do
|
63
63
|
subject = "apple"
|
64
64
|
subject.should_receive(:===).with("apple").and_return(true)
|
65
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected not === "apple"
|
65
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple")
|
66
66
|
subject.should_not === "apple"
|
67
67
|
end
|
68
68
|
|
@@ -79,7 +79,7 @@ describe "should =~" do
|
|
79
79
|
it "should fail when target.=~(actual) returns false" do
|
80
80
|
subject = "fu"
|
81
81
|
subject.should_receive(:=~).with(/oo/).and_return(false)
|
82
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected
|
82
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu")
|
83
83
|
subject.should =~ /oo/
|
84
84
|
end
|
85
85
|
|
@@ -96,7 +96,7 @@ describe "should_not =~" do
|
|
96
96
|
it "should fail when target.=~(actual) returns false" do
|
97
97
|
subject = "foo"
|
98
98
|
subject.should_receive(:=~).with(/oo/).and_return(true)
|
99
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected not =~ /oo
|
99
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo")
|
100
100
|
subject.should_not =~ /oo/
|
101
101
|
end
|
102
102
|
|
@@ -109,7 +109,7 @@ describe "should >" do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should fail if > fails" do
|
112
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected > 5
|
112
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4)
|
113
113
|
4.should > 5
|
114
114
|
end
|
115
115
|
|
@@ -123,7 +123,7 @@ describe "should >=" do
|
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should fail if > fails" do
|
126
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected >= 5
|
126
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4)
|
127
127
|
4.should >= 5
|
128
128
|
end
|
129
129
|
|
@@ -136,7 +136,7 @@ describe "should <" do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should fail if > fails" do
|
139
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected < 3
|
139
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4)
|
140
140
|
4.should < 3
|
141
141
|
end
|
142
142
|
|
@@ -150,7 +150,7 @@ describe "should <=" do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should fail if > fails" do
|
153
|
-
Spec::Expectations.should_receive(:fail_with).with(%[expected <= 3
|
153
|
+
Spec::Expectations.should_receive(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4)
|
154
154
|
4.should <= 3
|
155
155
|
end
|
156
156
|
|