rspec-expectations 2.11.3 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.document +1 -1
  4. data/.yardopts +1 -1
  5. data/Changelog.md +1026 -21
  6. data/{License.txt → LICENSE.md} +5 -3
  7. data/README.md +174 -78
  8. data/lib/rspec/expectations/block_snippet_extractor.rb +253 -0
  9. data/lib/rspec/expectations/configuration.rb +230 -0
  10. data/lib/rspec/expectations/expectation_target.rb +130 -55
  11. data/lib/rspec/expectations/fail_with.rb +17 -33
  12. data/lib/rspec/expectations/failure_aggregator.rb +212 -0
  13. data/lib/rspec/expectations/handler.rb +163 -29
  14. data/lib/rspec/expectations/minitest_integration.rb +58 -0
  15. data/lib/rspec/expectations/syntax.rb +68 -54
  16. data/lib/rspec/expectations/version.rb +1 -1
  17. data/lib/rspec/expectations.rb +59 -24
  18. data/lib/rspec/matchers/aliased_matcher.rb +116 -0
  19. data/lib/rspec/matchers/built_in/all.rb +86 -0
  20. data/lib/rspec/matchers/built_in/base_matcher.rb +150 -20
  21. data/lib/rspec/matchers/built_in/be.rb +115 -109
  22. data/lib/rspec/matchers/built_in/be_between.rb +77 -0
  23. data/lib/rspec/matchers/built_in/be_instance_of.rb +16 -1
  24. data/lib/rspec/matchers/built_in/be_kind_of.rb +10 -1
  25. data/lib/rspec/matchers/built_in/be_within.rb +43 -17
  26. data/lib/rspec/matchers/built_in/change.rb +392 -75
  27. data/lib/rspec/matchers/built_in/compound.rb +290 -0
  28. data/lib/rspec/matchers/built_in/contain_exactly.rb +302 -0
  29. data/lib/rspec/matchers/built_in/count_expectation.rb +169 -0
  30. data/lib/rspec/matchers/built_in/cover.rb +3 -0
  31. data/lib/rspec/matchers/built_in/eq.rb +26 -8
  32. data/lib/rspec/matchers/built_in/eql.rb +19 -8
  33. data/lib/rspec/matchers/built_in/equal.rb +56 -19
  34. data/lib/rspec/matchers/built_in/exist.rb +74 -10
  35. data/lib/rspec/matchers/built_in/has.rb +141 -22
  36. data/lib/rspec/matchers/built_in/have_attributes.rb +114 -0
  37. data/lib/rspec/matchers/built_in/include.rb +175 -20
  38. data/lib/rspec/matchers/built_in/match.rb +95 -1
  39. data/lib/rspec/matchers/built_in/operators.rb +128 -0
  40. data/lib/rspec/matchers/built_in/output.rb +207 -0
  41. data/lib/rspec/matchers/built_in/raise_error.rb +212 -38
  42. data/lib/rspec/matchers/built_in/respond_to.rb +155 -29
  43. data/lib/rspec/matchers/built_in/satisfy.rb +39 -9
  44. data/lib/rspec/matchers/built_in/start_or_end_with.rb +94 -0
  45. data/lib/rspec/matchers/built_in/throw_symbol.rb +58 -14
  46. data/lib/rspec/matchers/built_in/yield.rb +252 -98
  47. data/lib/rspec/matchers/built_in.rb +47 -33
  48. data/lib/rspec/matchers/composable.rb +171 -0
  49. data/lib/rspec/matchers/dsl.rb +530 -10
  50. data/lib/rspec/matchers/english_phrasing.rb +58 -0
  51. data/lib/rspec/matchers/expecteds_for_multiple_diffs.rb +82 -0
  52. data/lib/rspec/matchers/fail_matchers.rb +42 -0
  53. data/lib/rspec/matchers/generated_descriptions.rb +15 -10
  54. data/lib/rspec/matchers/matcher_delegator.rb +35 -0
  55. data/lib/rspec/matchers/matcher_protocol.rb +105 -0
  56. data/lib/rspec/matchers.rb +604 -252
  57. data.tar.gz.sig +0 -0
  58. metadata +178 -278
  59. metadata.gz.sig +0 -0
  60. data/features/README.md +0 -49
  61. data/features/Upgrade.md +0 -53
  62. data/features/built_in_matchers/README.md +0 -90
  63. data/features/built_in_matchers/be.feature +0 -173
  64. data/features/built_in_matchers/be_within.feature +0 -46
  65. data/features/built_in_matchers/cover.feature +0 -45
  66. data/features/built_in_matchers/end_with.feature +0 -46
  67. data/features/built_in_matchers/equality.feature +0 -145
  68. data/features/built_in_matchers/exist.feature +0 -43
  69. data/features/built_in_matchers/expect_change.feature +0 -59
  70. data/features/built_in_matchers/expect_error.feature +0 -138
  71. data/features/built_in_matchers/have.feature +0 -103
  72. data/features/built_in_matchers/include.feature +0 -121
  73. data/features/built_in_matchers/match.feature +0 -50
  74. data/features/built_in_matchers/operators.feature +0 -221
  75. data/features/built_in_matchers/predicates.feature +0 -128
  76. data/features/built_in_matchers/respond_to.feature +0 -78
  77. data/features/built_in_matchers/satisfy.feature +0 -31
  78. data/features/built_in_matchers/start_with.feature +0 -46
  79. data/features/built_in_matchers/throw_symbol.feature +0 -85
  80. data/features/built_in_matchers/types.feature +0 -114
  81. data/features/built_in_matchers/yield.feature +0 -146
  82. data/features/custom_matchers/access_running_example.feature +0 -53
  83. data/features/custom_matchers/define_diffable_matcher.feature +0 -27
  84. data/features/custom_matchers/define_matcher.feature +0 -340
  85. data/features/custom_matchers/define_matcher_outside_rspec.feature +0 -38
  86. data/features/custom_matchers/define_matcher_with_fluent_interface.feature +0 -24
  87. data/features/customized_message.feature +0 -22
  88. data/features/diffing.feature +0 -85
  89. data/features/implicit_docstrings.feature +0 -52
  90. data/features/step_definitions/additional_cli_steps.rb +0 -22
  91. data/features/support/env.rb +0 -5
  92. data/features/syntax_configuration.feature +0 -68
  93. data/features/test_frameworks/test_unit.feature +0 -46
  94. data/lib/rspec/expectations/deprecation.rb +0 -38
  95. data/lib/rspec/expectations/differ.rb +0 -81
  96. data/lib/rspec/expectations/errors.rb +0 -9
  97. data/lib/rspec/expectations/extensions/array.rb +0 -9
  98. data/lib/rspec/expectations/extensions/object.rb +0 -39
  99. data/lib/rspec/expectations/extensions.rb +0 -2
  100. data/lib/rspec/matchers/be_close.rb +0 -9
  101. data/lib/rspec/matchers/built_in/have.rb +0 -108
  102. data/lib/rspec/matchers/built_in/match_array.rb +0 -45
  103. data/lib/rspec/matchers/built_in/start_and_end_with.rb +0 -48
  104. data/lib/rspec/matchers/compatibility.rb +0 -14
  105. data/lib/rspec/matchers/configuration.rb +0 -66
  106. data/lib/rspec/matchers/extensions/instance_eval_with_args.rb +0 -39
  107. data/lib/rspec/matchers/matcher.rb +0 -299
  108. data/lib/rspec/matchers/method_missing.rb +0 -12
  109. data/lib/rspec/matchers/operator_matcher.rb +0 -84
  110. data/lib/rspec/matchers/pretty.rb +0 -60
  111. data/lib/rspec-expectations.rb +0 -1
  112. data/spec/rspec/expectations/differ_spec.rb +0 -153
  113. data/spec/rspec/expectations/expectation_target_spec.rb +0 -65
  114. data/spec/rspec/expectations/extensions/kernel_spec.rb +0 -67
  115. data/spec/rspec/expectations/fail_with_spec.rb +0 -70
  116. data/spec/rspec/expectations/handler_spec.rb +0 -206
  117. data/spec/rspec/matchers/base_matcher_spec.rb +0 -60
  118. data/spec/rspec/matchers/be_close_spec.rb +0 -22
  119. data/spec/rspec/matchers/be_instance_of_spec.rb +0 -40
  120. data/spec/rspec/matchers/be_kind_of_spec.rb +0 -37
  121. data/spec/rspec/matchers/be_spec.rb +0 -452
  122. data/spec/rspec/matchers/be_within_spec.rb +0 -80
  123. data/spec/rspec/matchers/change_spec.rb +0 -528
  124. data/spec/rspec/matchers/configuration_spec.rb +0 -202
  125. data/spec/rspec/matchers/cover_spec.rb +0 -69
  126. data/spec/rspec/matchers/description_generation_spec.rb +0 -176
  127. data/spec/rspec/matchers/dsl_spec.rb +0 -57
  128. data/spec/rspec/matchers/eq_spec.rb +0 -54
  129. data/spec/rspec/matchers/eql_spec.rb +0 -41
  130. data/spec/rspec/matchers/equal_spec.rb +0 -60
  131. data/spec/rspec/matchers/exist_spec.rb +0 -110
  132. data/spec/rspec/matchers/has_spec.rb +0 -118
  133. data/spec/rspec/matchers/have_spec.rb +0 -461
  134. data/spec/rspec/matchers/include_spec.rb +0 -367
  135. data/spec/rspec/matchers/match_array_spec.rb +0 -124
  136. data/spec/rspec/matchers/match_spec.rb +0 -61
  137. data/spec/rspec/matchers/matcher_spec.rb +0 -434
  138. data/spec/rspec/matchers/matchers_spec.rb +0 -31
  139. data/spec/rspec/matchers/method_missing_spec.rb +0 -24
  140. data/spec/rspec/matchers/operator_matcher_spec.rb +0 -221
  141. data/spec/rspec/matchers/raise_error_spec.rb +0 -344
  142. data/spec/rspec/matchers/respond_to_spec.rb +0 -295
  143. data/spec/rspec/matchers/satisfy_spec.rb +0 -44
  144. data/spec/rspec/matchers/start_with_end_with_spec.rb +0 -182
  145. data/spec/rspec/matchers/throw_symbol_spec.rb +0 -116
  146. data/spec/rspec/matchers/yield_spec.rb +0 -402
  147. data/spec/spec_helper.rb +0 -27
  148. data/spec/support/classes.rb +0 -56
  149. data/spec/support/in_sub_process.rb +0 -31
  150. data/spec/support/matchers.rb +0 -22
  151. data/spec/support/ruby_version.rb +0 -10
  152. data/spec/support/shared_examples.rb +0 -13
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Object, "#should" do
4
- before(:each) do
5
- @target = "target"
6
- @matcher = mock("matcher")
7
- @matcher.stub!(:matches?).and_return(true)
8
- @matcher.stub!(:failure_message_for_should)
9
- end
10
-
11
- it "accepts and interacts with a matcher" do
12
- @matcher.should_receive(:matches?).with(@target).and_return(true)
13
- @target.should @matcher
14
- end
15
-
16
- it "asks for a failure_message_for_should when matches? returns false" do
17
- @matcher.should_receive(:matches?).with(@target).and_return(false)
18
- @matcher.should_receive(:failure_message_for_should).and_return("the failure message")
19
- lambda {
20
- @target.should @matcher
21
- }.should fail_with("the failure message")
22
- end
23
-
24
- context "on interpretters that have BasicObject", :if => defined?(BasicObject) do
25
- let(:proxy_class) do
26
- Class.new(BasicObject) do
27
- def initialize(target)
28
- @target = target
29
- end
30
-
31
- def proxied?
32
- true
33
- end
34
-
35
- def method_missing(name, *args)
36
- @target.send(name, *args)
37
- end
38
- end
39
- end
40
-
41
- it 'works properly on BasicObject-subclassed proxy objects' do
42
- proxy_class.new(Object.new).should be_proxied
43
- end
44
- end
45
- end
46
-
47
- describe Object, "#should_not" do
48
- before(:each) do
49
- @target = "target"
50
- @matcher = mock("matcher")
51
- end
52
-
53
- it "accepts and interacts with a matcher" do
54
- @matcher.should_receive(:matches?).with(@target).and_return(false)
55
- @matcher.stub!(:failure_message_for_should_not)
56
-
57
- @target.should_not @matcher
58
- end
59
-
60
- it "asks for a failure_message_for_should_not when matches? returns true" do
61
- @matcher.should_receive(:matches?).with(@target).and_return(true)
62
- @matcher.should_receive(:failure_message_for_should_not).and_return("the failure message for should not")
63
- lambda {
64
- @target.should_not @matcher
65
- }.should fail_with("the failure message for should not")
66
- end
67
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RSpec::Expectations, "#fail_with with diff" do
4
- let(:differ) { double("differ") }
5
-
6
- before(:each) do
7
- RSpec::Expectations.stub(:differ) { differ }
8
- end
9
-
10
- it "calls differ if expected/actual are not strings (or numbers or procs)" do
11
- differ.should_receive(:diff_as_object).and_return("diff")
12
- lambda {
13
- RSpec::Expectations.fail_with "the message", Object.new, Object.new
14
- }.should fail_with("the message\nDiff:diff")
15
- end
16
-
17
- context "with two strings" do
18
- context "and actual is multiline" do
19
- it "calls differ" do
20
- differ.should_receive(:diff_as_string).and_return("diff")
21
- lambda {
22
- RSpec::Expectations.fail_with "the message", "expected\nthis", "actual"
23
- }.should fail_with("the message\nDiff:diff")
24
- end
25
- end
26
-
27
- context "and expected is multiline" do
28
- it "calls differ" do
29
- differ.should_receive(:diff_as_string).and_return("diff")
30
- lambda {
31
- RSpec::Expectations.fail_with "the message", "expected", "actual\nthat"
32
- }.should fail_with("the message\nDiff:diff")
33
- end
34
- end
35
-
36
- context "and both are single line strings" do
37
- it "does not call differ" do
38
- differ.should_not_receive(:diff_as_string)
39
- lambda {
40
- RSpec::Expectations.fail_with("the message", "expected", "actual")
41
- }.should fail_with("the message")
42
- end
43
- end
44
- end
45
-
46
- it "does not call differ if no expected/actual" do
47
- lambda {
48
- RSpec::Expectations.fail_with "the message"
49
- }.should fail_with("the message")
50
- end
51
-
52
- it "does not call differ expected is Numeric" do
53
- lambda {
54
- RSpec::Expectations.fail_with "the message", 1, "1"
55
- }.should fail_with("the message")
56
- end
57
-
58
- it "does not call differ when actual is Numeric" do
59
- lambda {
60
- RSpec::Expectations.fail_with "the message", "1", 1
61
- }.should fail_with("the message")
62
- end
63
-
64
- it "does not call differ if expected or actual are procs" do
65
- lambda {
66
- RSpec::Expectations.fail_with "the message", lambda {}, lambda {}
67
- }.should fail_with("the message")
68
- end
69
- end
70
-
@@ -1,206 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ExampleExpectations
4
-
5
- class ArbitraryMatcher
6
- def initialize(*args, &block)
7
- if args.last.is_a? Hash
8
- @expected = args.last[:expected]
9
- end
10
- @expected = block.call if block
11
- @block = block
12
- end
13
-
14
- def matches?(target)
15
- @target = target
16
- return @expected == target
17
- end
18
-
19
- def with(new_value)
20
- @expected = new_value
21
- self
22
- end
23
-
24
- def failure_message
25
- "expected #{@expected}, got #{@target}"
26
- end
27
-
28
- def negative_failure_message
29
- "expected not #{@expected}, got #{@target}"
30
- end
31
- end
32
-
33
- class PositiveOnlyMatcher < ArbitraryMatcher
34
- undef negative_failure_message rescue nil
35
- end
36
-
37
- def arbitrary_matcher(*args, &block)
38
- ArbitraryMatcher.new(*args, &block)
39
- end
40
-
41
- def positive_only_matcher(*args, &block)
42
- PositiveOnlyMatcher.new(*args, &block)
43
- end
44
-
45
- end
46
-
47
- module RSpec
48
- module Expectations
49
- describe PositiveExpectationHandler do
50
- describe "#handle_matcher" do
51
- it "asks the matcher if it matches" do
52
- matcher = mock("matcher")
53
- actual = Object.new
54
- matcher.should_receive(:matches?).with(actual).and_return(true)
55
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
56
- end
57
-
58
- it "returns the match value" do
59
- matcher = mock("matcher")
60
- actual = Object.new
61
- matcher.should_receive(:matches?).with(actual).and_return(:this_value)
62
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value
63
- end
64
-
65
- it "calls failure_message_for_should if the matcher implements it" do
66
- matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
67
- actual = Object.new
68
-
69
- ::RSpec::Expectations.should_receive(:fail_with).with("message")
70
-
71
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
72
- end
73
-
74
- it "calls fail if matcher.diffable?" do
75
- matcher = mock("matcher",
76
- :diffable? => true,
77
- :failure_message_for_should => "message",
78
- :matches? => false,
79
- :expected => 1,
80
- :actual => 2
81
- )
82
- actual = Object.new
83
-
84
- ::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
85
-
86
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
87
- end
88
-
89
- it "calls failure_message if the matcher does not implement failure_message_for_should" do
90
- matcher = mock("matcher", :failure_message => "message", :matches? => false)
91
- actual = Object.new
92
-
93
- ::RSpec::Expectations.should_receive(:fail_with).with("message")
94
-
95
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher)
96
-
97
- end
98
-
99
- it "appends the :or message in the options hash passed to should" do
100
- matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false)
101
- actual = Object.new
102
-
103
- ::RSpec::Expectations.should_receive(:fail_with).with("custom")
104
-
105
- RSpec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher, "custom")
106
- end
107
- end
108
- end
109
-
110
- describe NegativeExpectationHandler do
111
- describe "#handle_matcher" do
112
- it "asks the matcher if it doesn't match when the matcher responds to #does_not_match?" do
113
- matcher = mock("matcher", :does_not_match? => true, :negative_failure_message => nil)
114
- actual = Object.new
115
- matcher.should_receive(:does_not_match?).with(actual).and_return(true)
116
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
117
- end
118
-
119
- it "asks the matcher if it matches when the matcher doesn't respond to #does_not_match?" do
120
- matcher = mock("matcher")
121
- actual = Object.new
122
- matcher.stub!(:negative_failure_message)
123
- matcher.should_receive(:matches?).with(actual).and_return(false)
124
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
125
- end
126
-
127
- it "returns the match value" do
128
- matcher = mock("matcher")
129
- actual = Object.new
130
- matcher.should_receive(:matches?).with(actual).and_return(false)
131
- matcher.stub!(:negative_failure_message).and_return("ignore")
132
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher).should be_false
133
- end
134
-
135
-
136
- it "calls failure_message_for_should_not if the matcher implements it" do
137
- matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
138
- actual = Object.new
139
-
140
- ::RSpec::Expectations.should_receive(:fail_with).with("message")
141
-
142
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
143
-
144
- end
145
-
146
- it "calls negative_failure_message if the matcher does not implement failure_message_for_should_not" do
147
- matcher = mock("matcher", :negative_failure_message => "message", :matches? => true)
148
- actual = Object.new
149
-
150
- ::RSpec::Expectations.should_receive(:fail_with).with("message")
151
-
152
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
153
-
154
- end
155
-
156
-
157
- it "calls fail if matcher.diffable?" do
158
- matcher = mock("matcher",
159
- :diffable? => true,
160
- :failure_message_for_should_not => "message",
161
- :matches? => true,
162
- :expected => 1,
163
- :actual => 2
164
- )
165
- actual = Object.new
166
-
167
- ::RSpec::Expectations.should_receive(:fail_with).with("message", 1, 2)
168
-
169
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher)
170
- end
171
-
172
- it "appends the :or message in the options hash passed to should" do
173
- matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true)
174
- actual = Object.new
175
-
176
- ::RSpec::Expectations.should_receive(:fail_with).with("custom")
177
-
178
- RSpec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher, "custom")
179
- end
180
-
181
- end
182
- end
183
-
184
- describe PositiveExpectationHandler do
185
- include ExampleExpectations
186
-
187
- it "handles submitted args" do
188
- 5.should arbitrary_matcher(:expected => 5)
189
- 5.should arbitrary_matcher(:expected => "wrong").with(5)
190
- lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
191
- lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5")
192
- 5.should_not arbitrary_matcher(:expected => 4)
193
- 5.should_not arbitrary_matcher(:expected => 5).with(4)
194
- lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5")
195
- lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
196
- end
197
-
198
- it "handles the submitted block" do
199
- 5.should arbitrary_matcher { 5 }
200
- 5.should arbitrary_matcher(:expected => 4) { 5 }
201
- 5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
202
- end
203
-
204
- end
205
- end
206
- end
@@ -1,60 +0,0 @@
1
- module RSpec::Matchers::BuiltIn
2
- describe BaseMatcher do
3
- describe "#match_unless_raises" do
4
- let(:matcher) do
5
- Class.new(BaseMatcher).new
6
- end
7
-
8
- it "returns true if there are no errors" do
9
- matcher.match_unless_raises {}.should be_true
10
- end
11
-
12
- it "returns false if there is an error" do
13
- matcher.match_unless_raises { raise }.should be_false
14
- end
15
-
16
- it "returns false if the only submitted error is raised" do
17
- matcher.match_unless_raises(RuntimeError){ raise "foo" }.should be_false
18
- end
19
-
20
- it "returns false if any of several errors submitted is raised" do
21
- matcher.match_unless_raises(RuntimeError, ArgumentError, NameError) { raise "foo" }.should be_false
22
- matcher.match_unless_raises(RuntimeError, ArgumentError, NameError) { raise ArgumentError.new('') }.should be_false
23
- matcher.match_unless_raises(RuntimeError, ArgumentError, NameError) { raise NameError.new('') }.should be_false
24
- end
25
-
26
- it "re-raises any error other than one of those specified" do
27
- expect do
28
- matcher.match_unless_raises(ArgumentError){ raise "foo" }
29
- end.to raise_error
30
- end
31
-
32
- it "stores the rescued exception for use in messages" do
33
- matcher.match_unless_raises(RuntimeError){ raise "foo" }
34
- matcher.rescued_exception.should be_a(RuntimeError)
35
- matcher.rescued_exception.message.should eq("foo")
36
- end
37
-
38
- end
39
-
40
- describe "#==" do
41
- it "responds the same way as matches?" do
42
- matcher = Class.new(BaseMatcher) do
43
- def initialize(expected)
44
- @expected = expected
45
- end
46
-
47
- def matches?(actual)
48
- (@actual = actual) == @expected
49
- end
50
- end
51
-
52
- matcher.new(3).matches?(3).should be_true
53
- matcher.new(3).should eq(3)
54
-
55
- matcher.new(3).matches?(4).should be_false
56
- matcher.new(3).should_not eq(4)
57
- end
58
- end
59
- end
60
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Matchers
5
- describe "[actual.should] be_close(expected, delta)" do
6
- before(:each) do
7
- RSpec.stub(:warn)
8
- end
9
-
10
- it "delegates to be_within(delta).of(expected)" do
11
- should_receive(:be_within).with(0.5).and_return( be_within_matcher = stub )
12
- be_within_matcher.should_receive(:of).with(3.0)
13
- be_close(3.0, 0.5)
14
- end
15
-
16
- it "prints a deprecation warning" do
17
- RSpec.should_receive(:warn).with(/please use be_within.*instead/)
18
- be_close(3.0, 0.5)
19
- end
20
- end
21
- end
22
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Matchers
5
- [:be_an_instance_of, :be_instance_of].each do |method|
6
- describe "actual.should #{method}(expected)" do
7
- it_behaves_like "an RSpec matcher", :valid_value => 5, :invalid_value => "a" do
8
- let(:matcher) { send(method, Fixnum) }
9
- end
10
-
11
- it "passes if actual is instance of expected class" do
12
- 5.should send(method, Fixnum)
13
- end
14
-
15
- it "fails if actual is instance of subclass of expected class" do
16
- lambda { 5.should send(method, Numeric) }.should fail_with(%Q{expected 5 to be an instance of Numeric})
17
- end
18
-
19
- it "fails with failure message for should unless actual is instance of expected class" do
20
- lambda { "foo".should send(method, Array) }.should fail_with(%Q{expected "foo" to be an instance of Array})
21
- end
22
-
23
- it "provides a description" do
24
- matcher = be_an_instance_of(Fixnum)
25
- matcher.matches?(Numeric)
26
- matcher.description.should == "be an instance of Fixnum"
27
- end
28
- end
29
-
30
- describe "actual.should_not #{method}(expected)" do
31
-
32
- it "fails with failure message for should_not if actual is instance of expected class" do
33
- lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be an instance of String})
34
- end
35
-
36
- end
37
-
38
- end
39
- end
40
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Matchers
5
- [:be_a_kind_of, :be_kind_of].each do |method|
6
- describe "actual.should #{method}(expected)" do
7
- it_behaves_like "an RSpec matcher", :valid_value => 5, :invalid_value => "a" do
8
- let(:matcher) { send(method, Fixnum) }
9
- end
10
-
11
- it "passes if actual is instance of expected class" do
12
- 5.should send(method, Fixnum)
13
- end
14
-
15
- it "passes if actual is instance of subclass of expected class" do
16
- 5.should send(method, Numeric)
17
- end
18
-
19
- it "fails with failure message for should unless actual is kind of expected class" do
20
- lambda { "foo".should send(method, Array) }.should fail_with(%Q{expected "foo" to be a kind of Array})
21
- end
22
-
23
- it "provides a description" do
24
- matcher = be_a_kind_of(String)
25
- matcher.matches?("this")
26
- matcher.description.should == "be a kind of String"
27
- end
28
- end
29
-
30
- describe "actual.should_not #{method}(expected)" do
31
- it "fails with failure message for should_not if actual is kind of expected class" do
32
- lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be a kind of String})
33
- end
34
- end
35
- end
36
- end
37
- end