rspec 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +31 -1
- data/Manifest.txt +14 -12
- data/Rakefile +1 -1
- data/Upgrade.rdoc +43 -3
- data/examples/failing/failing_implicit_docstrings_example.rb +5 -5
- data/examples/passing/implicit_docstrings_example.rb +3 -3
- data/features/before_and_after_blocks/before_and_after_blocks.feature +20 -21
- data/features/example_groups/example_group_with_should_methods.feature +20 -8
- data/features/example_groups/implicit_docstrings.feature +36 -20
- data/features/example_groups/nested_groups.feature +25 -10
- data/features/extensions/custom_example_group.feature +19 -0
- data/features/formatters/custom_formatter.feature +30 -0
- data/features/heckle/heckle.feature +7 -7
- data/features/interop/examples_and_tests_together.feature +63 -14
- data/features/interop/rspec_output.feature +25 -0
- data/features/interop/test_but_not_test_unit.feature +19 -7
- data/features/interop/test_case_with_should_methods.feature +37 -8
- data/features/matchers/{create_matcher.feature → define_matcher.feature} +54 -30
- data/features/matchers/{create_matcher_outside_rspec.feature → define_matcher_outside_rspec.feature} +7 -7
- data/features/mock_framework_integration/use_flexmock.feature +3 -3
- data/features/mock_framework_integration/use_mocha.feature +3 -3
- data/features/mock_framework_integration/use_rr.feature +3 -3
- data/features/mocks/mix_stubs_and_mocks.feature +4 -4
- data/features/pending/pending_examples.feature +18 -18
- data/features/runner/specify_line_number.feature +32 -0
- data/features/step_definitions/running_rspec_steps.rb +41 -0
- data/features/subject/explicit_subject.feature +4 -4
- data/features/subject/implicit_subject.feature +4 -4
- data/features/support/env.rb +64 -11
- data/features/support/matchers/smart_match.rb +10 -35
- data/lib/spec.rb +1 -0
- data/lib/spec/deprecation.rb +40 -0
- data/lib/spec/dsl/main.rb +10 -5
- data/lib/spec/example.rb +1 -27
- data/lib/spec/example/args_and_options.rb +27 -0
- data/lib/spec/example/before_and_after_hooks.rb +30 -21
- data/lib/spec/example/errors.rb +8 -18
- data/lib/spec/example/example_group_factory.rb +0 -4
- data/lib/spec/example/example_group_methods.rb +27 -41
- data/lib/spec/example/example_group_proxy.rb +12 -22
- data/lib/spec/example/example_methods.rb +8 -18
- data/lib/spec/example/example_proxy.rb +4 -4
- data/lib/spec/example/pending.rb +3 -4
- data/lib/spec/example/predicate_matchers.rb +1 -1
- data/lib/spec/example/subject.rb +2 -0
- data/lib/spec/expectations.rb +1 -26
- data/lib/spec/expectations/extensions.rb +1 -1
- data/lib/spec/expectations/extensions/kernel.rb +52 -0
- data/lib/spec/expectations/handler.rb +21 -10
- data/lib/spec/matchers/be.rb +3 -3
- data/lib/spec/matchers/be_close.rb +17 -21
- data/lib/spec/matchers/be_instance_of.rb +7 -26
- data/lib/spec/matchers/be_kind_of.rb +7 -26
- data/lib/spec/matchers/dsl.rb +9 -4
- data/lib/spec/matchers/eql.rb +24 -25
- data/lib/spec/matchers/equal.rb +25 -25
- data/lib/spec/matchers/exist.rb +5 -21
- data/lib/spec/matchers/include.rb +22 -44
- data/lib/spec/matchers/match.rb +5 -25
- data/lib/spec/matchers/match_array.rb +8 -4
- data/lib/spec/matchers/matcher.rb +13 -2
- data/lib/spec/matchers/pretty.rb +1 -0
- data/lib/spec/matchers/simple_matcher.rb +2 -2
- data/lib/spec/mocks/mock.rb +10 -10
- data/lib/spec/mocks/spec_methods.rb +1 -1
- data/lib/spec/runner/configuration.rb +53 -42
- data/lib/spec/{expectations → runner}/differs/default.rb +0 -0
- data/lib/spec/{expectations → runner}/differs/load-diff-lcs.rb +0 -0
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/example_group_runner.rb +0 -12
- data/lib/spec/runner/formatter/base_formatter.rb +77 -30
- data/lib/spec/runner/formatter/base_text_formatter.rb +19 -24
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +1 -1
- data/lib/spec/runner/formatter/html_formatter.rb +4 -6
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/formatter/no_op_method_missing.rb +21 -0
- data/lib/spec/runner/formatter/profile_formatter.rb +0 -4
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +4 -5
- data/lib/spec/runner/formatter/silent_formatter.rb +10 -0
- data/lib/spec/runner/formatter/specdoc_formatter.rb +2 -2
- data/lib/spec/runner/option_parser.rb +14 -7
- data/lib/spec/runner/options.rb +17 -7
- data/lib/spec/runner/reporter.rb +69 -64
- data/lib/spec/version.rb +1 -1
- data/spec/spec/dsl/main_spec.rb +7 -0
- data/spec/spec/example/example_group_methods_spec.rb +16 -32
- data/spec/spec/example/example_group_proxy_spec.rb +25 -5
- data/spec/spec/example/example_group_spec.rb +2 -2
- data/spec/spec/example/example_methods_spec.rb +19 -24
- data/spec/spec/example/example_proxy_spec.rb +11 -1
- data/spec/spec/example/pending_module_spec.rb +2 -108
- data/spec/spec/example/predicate_matcher_spec.rb +23 -3
- data/spec/spec/expectations/extensions/object_spec.rb +9 -9
- data/spec/spec/expectations/fail_with_spec.rb +13 -13
- data/spec/spec/expectations/handler_spec.rb +44 -15
- data/spec/spec/matchers/be_close_spec.rb +9 -0
- data/spec/spec/matchers/be_instance_of_spec.rb +6 -4
- data/spec/spec/matchers/be_kind_of_spec.rb +5 -3
- data/spec/spec/matchers/be_spec.rb +1 -5
- data/spec/spec/matchers/compatibility_spec.rb +1 -1
- data/spec/spec/matchers/dsl_spec.rb +10 -1
- data/spec/spec/matchers/eql_spec.rb +8 -4
- data/spec/spec/matchers/equal_spec.rb +8 -4
- data/spec/spec/matchers/exist_spec.rb +1 -1
- data/spec/spec/matchers/include_spec.rb +1 -1
- data/spec/spec/matchers/match_array_spec.rb +26 -1
- data/spec/spec/matchers/match_spec.rb +2 -2
- data/spec/spec/matchers/matcher_methods_spec.rb +0 -3
- data/spec/spec/matchers/matcher_spec.rb +53 -0
- data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
- data/spec/spec/mocks/mock_spec.rb +6 -0
- data/spec/spec/runner/configuration_spec.rb +11 -1
- data/spec/spec/runner/drb_command_line_spec.rb +13 -1
- data/spec/spec/runner/example_group_runner_spec.rb +0 -7
- data/spec/spec/runner/formatter/base_formatter_spec.rb +19 -12
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +2 -2
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +31 -34
- data/spec/spec/runner/formatter/html_formatter_spec.rb +20 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -20
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +22 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +24 -3
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +25 -28
- data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +2 -2
- data/spec/spec/runner/option_parser_spec.rb +108 -40
- data/spec/spec/runner/reporter_spec.rb +16 -17
- data/spec/spec_helper.rb +4 -1
- metadata +20 -18
- data/features/example_groups/output.feature +0 -20
- data/features/step_definitions/running_rspec.rb +0 -69
- data/lib/spec/expectations/extensions/object.rb +0 -63
- data/resources/spec/example_group_with_should_methods.rb +0 -12
- data/resources/spec/simple_spec.rb +0 -8
- data/resources/test/spec_and_test_together.rb +0 -56
- data/resources/test/spec_including_test_but_not_unit.rb +0 -11
- data/resources/test/test_case_with_should_methods.rb +0 -29
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
@@ -47,6 +47,14 @@ module Spec
|
|
47
47
|
@child_example_group.location.should =~ /#{__FILE__}:#{__LINE__ - 15}/
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe "when creating an example group with no description" do
|
52
|
+
it "raises an ArgumentError" do
|
53
|
+
lambda do
|
54
|
+
Class.new(ExampleGroupDouble).describe
|
55
|
+
end.should raise_error(Spec::Example::NoDescriptionError, /No description supplied for example group declared on #{__FILE__}:#{__LINE__ - 1}/)
|
56
|
+
end
|
57
|
+
end
|
50
58
|
|
51
59
|
describe "when creating a SharedExampleGroup" do
|
52
60
|
before(:each) do
|
@@ -79,6 +87,7 @@ module Spec
|
|
79
87
|
before(:all) do
|
80
88
|
@example_group = Class.new(ExampleGroupDouble).describe("bar")
|
81
89
|
@example_proxy = @example_group.__send__(method, "foo", {:this => :that}) {}
|
90
|
+
@location = "#{__FILE__}:#{__LINE__ - 1}"
|
82
91
|
end
|
83
92
|
|
84
93
|
specify "with a description" do
|
@@ -89,12 +98,13 @@ module Spec
|
|
89
98
|
@example_proxy.options.should == {:this => :that}
|
90
99
|
end
|
91
100
|
|
92
|
-
specify "with a default backtrace" do
|
93
|
-
|
101
|
+
specify "with a default backtrace (DEPRECATED)" do
|
102
|
+
Spec.stub!(:deprecate)
|
103
|
+
@example_proxy.backtrace.should =~ /#{@location}/
|
94
104
|
end
|
95
105
|
|
96
106
|
specify "with a default location" do
|
97
|
-
@example_proxy.location.should =~ /#{
|
107
|
+
@example_proxy.location.should =~ /#{@location}/
|
98
108
|
end
|
99
109
|
end
|
100
110
|
end
|
@@ -106,7 +116,8 @@ module Spec
|
|
106
116
|
@example_proxy = @example_group.__send__(method, "foo", {:this => :that}, "the location") {}
|
107
117
|
end
|
108
118
|
|
109
|
-
specify "with the supplied location as #backtrace" do
|
119
|
+
specify "with the supplied location as #backtrace (DEPRECATED)" do
|
120
|
+
Spec.stub!(:deprecate)
|
110
121
|
@example_proxy.backtrace.should == "the location"
|
111
122
|
end
|
112
123
|
|
@@ -593,33 +604,6 @@ module Spec
|
|
593
604
|
end
|
594
605
|
end
|
595
606
|
|
596
|
-
describe "#backtrace" do
|
597
|
-
it "returns the backtrace from where the example group was defined" do
|
598
|
-
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
599
|
-
example "bar" do; end
|
600
|
-
end
|
601
|
-
example_group.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
602
|
-
end
|
603
|
-
end
|
604
|
-
|
605
|
-
describe "#example_group_backtrace (deprecated)" do
|
606
|
-
before(:each) do
|
607
|
-
Kernel.stub!(:warn)
|
608
|
-
end
|
609
|
-
it "sends a deprecation warning" do
|
610
|
-
example_group = Class.new(ExampleGroupDouble) {}
|
611
|
-
Kernel.should_receive(:warn).with(/#example_group_backtrace.*deprecated.*#backtrace instead/m)
|
612
|
-
example_group.example_group_backtrace
|
613
|
-
end
|
614
|
-
|
615
|
-
it "returns the backtrace from where the example group was defined" do
|
616
|
-
example_group = Class.new(ExampleGroupDouble).describe("foo") do
|
617
|
-
example "bar" do; end
|
618
|
-
end
|
619
|
-
example_group.example_group_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-3}")
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
607
|
describe "#before" do
|
624
608
|
it "stores before(:each) blocks" do
|
625
609
|
example_group = Class.new(ExampleGroupDouble) {}
|
@@ -26,14 +26,24 @@ module Spec
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe "#filtered_description" do
|
29
|
+
describe "#filtered_description (DEPRECATED)" do
|
30
|
+
before(:each) do
|
31
|
+
Spec.stub!(:deprecate)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "is deprecated" do
|
35
|
+
Spec.should_receive(:deprecate)
|
36
|
+
proxy.filtered_description(/(ignore)/)
|
37
|
+
end
|
38
|
+
|
30
39
|
it "builds the description from the group's nested_descriptions" do
|
31
40
|
group.stub!(:nested_descriptions => ["ignore","the","description"])
|
32
|
-
proxy.filtered_description(/ignore/).should == "the description"
|
41
|
+
proxy.filtered_description(/(ignore)/).should == "the description"
|
33
42
|
end
|
43
|
+
|
34
44
|
it "filters out description parts that match the supplied regexp" do
|
35
|
-
group.stub!(:nested_descriptions => ["ignore
|
36
|
-
proxy.filtered_description(/ignore/).should == "the description"
|
45
|
+
group.stub!(:nested_descriptions => ["ignore the","description"])
|
46
|
+
proxy.filtered_description(/(ignore )/).should == "the description"
|
37
47
|
end
|
38
48
|
end
|
39
49
|
|
@@ -45,10 +55,20 @@ module Spec
|
|
45
55
|
end
|
46
56
|
|
47
57
|
describe "#backtrace (deprecated - use #location)" do
|
58
|
+
before(:each) do
|
59
|
+
Spec.stub!(:deprecate)
|
60
|
+
end
|
61
|
+
|
48
62
|
it "provides the location of the declaration of this group" do
|
49
|
-
group.stub!(:
|
63
|
+
group.stub!(:location => "path/to/location:37")
|
50
64
|
proxy.backtrace.should == "path/to/location:37"
|
51
65
|
end
|
66
|
+
|
67
|
+
it "warns deprecation" do
|
68
|
+
Spec.should_receive(:deprecate)
|
69
|
+
group.stub!(:location => "path/to/location:37")
|
70
|
+
proxy.backtrace
|
71
|
+
end
|
52
72
|
end
|
53
73
|
|
54
74
|
describe "#location" do
|
@@ -278,9 +278,9 @@ module Spec
|
|
278
278
|
ExampleGroupFactory.reset
|
279
279
|
end
|
280
280
|
|
281
|
-
it "should send reporter
|
281
|
+
it "should send reporter example_group_started" do
|
282
|
+
reporter.should_receive(:example_group_started)
|
282
283
|
example_group.run(options)
|
283
|
-
reporter.example_groups.should == [example_group]
|
284
284
|
end
|
285
285
|
|
286
286
|
it "should run example on run" do
|
@@ -32,30 +32,6 @@ module Spec
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
describe "#backtrace" do
|
36
|
-
it "returns the backtrace from where the example was defined" do
|
37
|
-
example = ExampleGroup.dup.new ExampleProxy.new
|
38
|
-
example.backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#implementation_backtrace (deprecated)" do
|
43
|
-
before(:each) do
|
44
|
-
Kernel.stub!(:warn)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "sends a deprecation warning" do
|
48
|
-
Kernel.should_receive(:warn).with(/#implementation_backtrace.*deprecated.*#backtrace instead/m)
|
49
|
-
example = ExampleGroup.dup.new ExampleProxy.new
|
50
|
-
example.implementation_backtrace
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns the backtrace from where the example was defined" do
|
54
|
-
example = ExampleGroup.dup.new ExampleProxy.new
|
55
|
-
example.implementation_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
35
|
describe "#should" do
|
60
36
|
before(:each) do
|
61
37
|
@example_group = Class.new(ExampleGroupDouble)
|
@@ -122,6 +98,25 @@ module Spec
|
|
122
98
|
example.options[:this].should == 'that'
|
123
99
|
end
|
124
100
|
end
|
101
|
+
|
102
|
+
describe "#description" do
|
103
|
+
it "returns the supplied description" do
|
104
|
+
example = ExampleGroupDouble.new ExampleProxy.new("name") do; end
|
105
|
+
example.description.should == "name"
|
106
|
+
end
|
107
|
+
it "returns the generated description if there is no description supplied" do
|
108
|
+
example = ExampleGroupDouble.new ExampleProxy.new do; end
|
109
|
+
Spec::Matchers.stub!(:generated_description).and_return('this message')
|
110
|
+
example.description.should == "this message"
|
111
|
+
end
|
112
|
+
it "raises if there is no supplied or generated description" do
|
113
|
+
example = ExampleGroupDouble.new ExampleProxy.new(nil, {}, "this backtrace") do; end
|
114
|
+
Spec::Matchers.stub!(:generated_description).and_return(nil)
|
115
|
+
lambda do
|
116
|
+
example.description
|
117
|
+
end.should raise_error(/No description supplied for example declared on this backtrace/)
|
118
|
+
end
|
119
|
+
end
|
125
120
|
|
126
121
|
end
|
127
122
|
end
|
@@ -27,7 +27,17 @@ module Spec
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe "#backtrace (
|
30
|
+
describe "#backtrace (DEPRECATED - use #location)" do
|
31
|
+
before(:each) do
|
32
|
+
Spec.stub!(:deprecate)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "is deprecated" do
|
36
|
+
Spec.should_receive(:deprecate)
|
37
|
+
proxy = ExampleProxy.new(:ignore, {}, "path/to/location:37")
|
38
|
+
proxy.backtrace
|
39
|
+
end
|
40
|
+
|
31
41
|
it "provides the location of the declaration of this group" do
|
32
42
|
proxy = ExampleProxy.new(:ignore, {}, "path/to/location:37")
|
33
43
|
proxy.backtrace.should == "path/to/location:37"
|
@@ -8,17 +8,6 @@ module Spec
|
|
8
8
|
pending "TODO"
|
9
9
|
}.should raise_error(ExamplePendingError, /TODO/)
|
10
10
|
end
|
11
|
-
|
12
|
-
it "reports the file and line number" do
|
13
|
-
file = __FILE__
|
14
|
-
line_number = __LINE__ + 2
|
15
|
-
begin
|
16
|
-
pending("TODO")
|
17
|
-
rescue => error
|
18
|
-
ensure
|
19
|
-
error.pending_caller.should =~ /^#{file}:#{line_number}/
|
20
|
-
end
|
21
|
-
end
|
22
11
|
end
|
23
12
|
|
24
13
|
context "when the supplied block fails" do
|
@@ -29,19 +18,6 @@ module Spec
|
|
29
18
|
end
|
30
19
|
}.should raise_error(ExamplePendingError, /TODO/)
|
31
20
|
end
|
32
|
-
|
33
|
-
it "reports the file and line number" do
|
34
|
-
file = __FILE__
|
35
|
-
line_number = __LINE__ + 2
|
36
|
-
begin
|
37
|
-
pending do
|
38
|
-
raise
|
39
|
-
end
|
40
|
-
rescue => error
|
41
|
-
ensure
|
42
|
-
error.pending_caller.should =~ /#{file}:#{line_number}/
|
43
|
-
end
|
44
|
-
end
|
45
21
|
end
|
46
22
|
|
47
23
|
context "when the supplied block fails with a mock" do
|
@@ -54,21 +30,6 @@ module Spec
|
|
54
30
|
end
|
55
31
|
}.should raise_error(ExamplePendingError, /TODO/)
|
56
32
|
end
|
57
|
-
|
58
|
-
it "reports the file and line number" do
|
59
|
-
file = __FILE__
|
60
|
-
line_number = __LINE__ + 2
|
61
|
-
begin
|
62
|
-
pending do
|
63
|
-
m = mock("thing")
|
64
|
-
m.should_receive(:foo)
|
65
|
-
m.rspec_verify
|
66
|
-
end
|
67
|
-
rescue => error
|
68
|
-
ensure
|
69
|
-
error.pending_caller.should =~ /#{file}:#{line_number}/
|
70
|
-
end
|
71
|
-
end
|
72
33
|
end
|
73
34
|
|
74
35
|
context "when the supplied block passes" do
|
@@ -83,81 +44,14 @@ module Spec
|
|
83
44
|
end
|
84
45
|
|
85
46
|
describe ExamplePendingError do
|
86
|
-
it "should have the caller (from two calls from initialization)" do
|
87
|
-
two_calls_ago = caller[0]
|
88
|
-
ExamplePendingError.new("a message").pending_caller.should == two_calls_ago
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should keep the trace information from initialization" do
|
92
|
-
two_calls_ago = caller[0]
|
93
|
-
obj = ExamplePendingError.new("a message")
|
94
|
-
obj.pending_caller
|
95
|
-
def another_caller(obj)
|
96
|
-
obj.pending_caller
|
97
|
-
end
|
98
|
-
|
99
|
-
another_caller(obj).should == two_calls_ago
|
100
|
-
end
|
101
|
-
|
102
47
|
it "should have the message provided" do
|
103
48
|
ExamplePendingError.new("a message").message.should == "a message"
|
104
49
|
end
|
105
|
-
|
106
|
-
it "should use a 'ExamplePendingError' as it's default message" do
|
107
|
-
ExamplePendingError.new.message.should == "Spec::Example::ExamplePendingError"
|
108
|
-
end
|
109
50
|
end
|
110
51
|
|
111
52
|
describe NotYetImplementedError do
|
112
|
-
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should have the root rspec path" do
|
117
|
-
NotYetImplementedError::RSPEC_ROOT_LIB.should == rspec_root
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should always have the error 'Not Yet Implemented'" do
|
121
|
-
NotYetImplementedError.new([]).message.should == "Not Yet Implemented"
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "pending_caller" do
|
125
|
-
it "should select an element out of the backtrace" do
|
126
|
-
error = NotYetImplementedError.new(["foo/bar.rb:18"])
|
127
|
-
|
128
|
-
error.pending_caller.should == "foo/bar.rb:18"
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should actually report the element from the backtrace" do
|
132
|
-
error = NotYetImplementedError.new(["bar.rb:18"])
|
133
|
-
|
134
|
-
error.pending_caller.should == "bar.rb:18"
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should not use an element with the rspec root path" do
|
138
|
-
error = NotYetImplementedError.new(["#{rspec_root}:8"])
|
139
|
-
|
140
|
-
error.pending_caller.should be_nil
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should select the first line in the backtrace which isn't in the rspec root" do
|
144
|
-
error = NotYetImplementedError.new([
|
145
|
-
"#{rspec_root}/foo.rb:2",
|
146
|
-
"#{rspec_root}/foo/bar.rb:18",
|
147
|
-
"path1.rb:22",
|
148
|
-
"path2.rb:33"
|
149
|
-
])
|
150
|
-
|
151
|
-
error.pending_caller.should == "path1.rb:22"
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should cache the caller" do
|
155
|
-
backtrace = mock('backtrace')
|
156
|
-
backtrace.should_receive(:detect).once
|
157
|
-
|
158
|
-
error = NotYetImplementedError.new(backtrace)
|
159
|
-
error.pending_caller.should == error.pending_caller
|
160
|
-
end
|
53
|
+
it "should have the message 'Not Yet Implemented'" do
|
54
|
+
NotYetImplementedError.new.message.should == "Not Yet Implemented"
|
161
55
|
end
|
162
56
|
end
|
163
57
|
end
|
@@ -9,12 +9,32 @@ module Spec
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "predicate_matcher[method_on_object] = matcher_method" do
|
12
|
-
|
12
|
+
before(:each) do
|
13
|
+
Spec.stub!(:deprecate)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is deprecated" do
|
17
|
+
Spec.should_receive(:deprecate)
|
18
|
+
group = ExampleGroupDouble.describe("foo") do
|
19
|
+
predicate_matchers[:swim] = :can_swim?
|
20
|
+
end
|
21
|
+
group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new))
|
22
|
+
end
|
23
|
+
|
13
24
|
it "should match matcher_method if method_on_object returns true" do
|
14
|
-
|
25
|
+
group = ExampleGroupDouble.describe(Fish) do
|
26
|
+
predicate_matchers[:swim] = :can_swim?
|
27
|
+
it { should swim(100) }
|
28
|
+
end
|
29
|
+
group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new))
|
15
30
|
end
|
31
|
+
|
16
32
|
it "should not match matcher_method if method_on_object returns false" do
|
17
|
-
|
33
|
+
group = ExampleGroupDouble.describe(Fish) do
|
34
|
+
predicate_matchers[:swim] = :can_swim?
|
35
|
+
it { should_not swim(1000) }
|
36
|
+
end
|
37
|
+
group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new))
|
18
38
|
end
|
19
39
|
end
|
20
40
|
end
|
@@ -5,17 +5,17 @@ describe Object, "#should" do
|
|
5
5
|
@target = "target"
|
6
6
|
@matcher = mock("matcher")
|
7
7
|
@matcher.stub!(:matches?).and_return(true)
|
8
|
-
@matcher.stub!(:
|
8
|
+
@matcher.stub!(:failure_message_for_should)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "accepts and interacts with a matcher" do
|
12
12
|
@matcher.should_receive(:matches?).with(@target).and_return(true)
|
13
13
|
@target.should @matcher
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "asks for a failure_message_for_should when matches? returns false" do
|
17
17
|
@matcher.should_receive(:matches?).with(@target).and_return(false)
|
18
|
-
@matcher.should_receive(:
|
18
|
+
@matcher.should_receive(:failure_message_for_should).and_return("the failure message")
|
19
19
|
lambda {
|
20
20
|
@target.should @matcher
|
21
21
|
}.should fail_with("the failure message")
|
@@ -28,18 +28,18 @@ describe Object, "#should_not" do
|
|
28
28
|
@matcher = mock("matcher")
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "accepts and interacts with a matcher" do
|
32
32
|
@matcher.should_receive(:matches?).with(@target).and_return(false)
|
33
|
-
@matcher.stub!(:
|
33
|
+
@matcher.stub!(:failure_message_for_should_not)
|
34
34
|
|
35
35
|
@target.should_not @matcher
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "asks for a failure_message_for_should_not when matches? returns true" do
|
39
39
|
@matcher.should_receive(:matches?).with(@target).and_return(true)
|
40
|
-
@matcher.should_receive(:
|
40
|
+
@matcher.should_receive(:failure_message_for_should_not).and_return("the failure message for should not")
|
41
41
|
lambda {
|
42
42
|
@target.should_not @matcher
|
43
|
-
}.should fail_with("the
|
43
|
+
}.should fail_with("the failure message for should not")
|
44
44
|
end
|
45
45
|
end
|