rr 1.0.5 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGES.md +24 -0
  3. data/LICENSE +2 -2
  4. data/README.md +124 -741
  5. data/VERSION +1 -1
  6. data/lib/rr.rb +2 -103
  7. data/lib/rr/adapters/minitest.rb +21 -13
  8. data/lib/rr/adapters/minitest_active_support.rb +34 -0
  9. data/lib/rr/adapters/none.rb +17 -0
  10. data/lib/rr/adapters/{rspec.rb → rspec/invocation_matcher.rb} +2 -27
  11. data/lib/rr/adapters/rspec_1.rb +42 -0
  12. data/lib/rr/adapters/rspec_2.rb +24 -0
  13. data/lib/rr/adapters/test_unit_1.rb +54 -0
  14. data/lib/rr/adapters/test_unit_2.rb +13 -0
  15. data/lib/rr/adapters/test_unit_2_active_support.rb +35 -0
  16. data/lib/rr/autohook.rb +43 -0
  17. data/lib/rr/core_ext/array.rb +12 -0
  18. data/lib/rr/core_ext/enumerable.rb +16 -0
  19. data/lib/rr/core_ext/hash.rb +20 -0
  20. data/lib/rr/core_ext/range.rb +8 -0
  21. data/lib/rr/core_ext/regexp.rb +8 -0
  22. data/lib/rr/double.rb +4 -4
  23. data/lib/rr/double_definitions/double_definition.rb +9 -3
  24. data/lib/rr/errors.rb +21 -0
  25. data/lib/rr/expectations/argument_equality_expectation.rb +10 -7
  26. data/lib/rr/expectations/times_called_expectation.rb +2 -8
  27. data/lib/rr/injections/double_injection.rb +1 -1
  28. data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
  29. data/lib/rr/recorded_calls.rb +12 -12
  30. data/lib/rr/space.rb +5 -3
  31. data/lib/rr/times_called_matchers/never_matcher.rb +2 -2
  32. data/lib/rr/wildcard_matchers/anything.rb +2 -2
  33. data/lib/rr/wildcard_matchers/boolean.rb +3 -7
  34. data/lib/rr/wildcard_matchers/duck_type.rb +11 -15
  35. data/lib/rr/wildcard_matchers/hash_including.rb +14 -13
  36. data/lib/rr/wildcard_matchers/is_a.rb +6 -7
  37. data/lib/rr/wildcard_matchers/satisfy.rb +8 -8
  38. data/lib/rr/without_autohook.rb +112 -0
  39. data/rr.gemspec +28 -0
  40. data/spec/global_helper.rb +12 -0
  41. data/spec/suite.rb +93 -0
  42. data/spec/suites/common/adapter_tests.rb +37 -0
  43. data/spec/suites/common/rails_integration_test.rb +175 -0
  44. data/spec/suites/common/test_unit_tests.rb +25 -0
  45. data/spec/suites/minitest/integration/minitest_test.rb +13 -0
  46. data/spec/suites/minitest/test_helper.rb +3 -0
  47. data/spec/suites/rspec_1/integration/rspec_1_spec.rb +20 -0
  48. data/spec/suites/rspec_1/integration/test_unit_1_rails_spec.rb +19 -0
  49. data/spec/suites/rspec_1/integration/test_unit_2_rails_spec.rb +18 -0
  50. data/spec/suites/rspec_1/spec_helper.rb +24 -0
  51. data/spec/suites/rspec_2/functional/any_instance_of_spec.rb +47 -0
  52. data/spec/suites/rspec_2/functional/dont_allow_spec.rb +12 -0
  53. data/spec/suites/rspec_2/functional/dsl_spec.rb +13 -0
  54. data/spec/suites/rspec_2/functional/instance_of_spec.rb +14 -0
  55. data/spec/suites/rspec_2/functional/mock_spec.rb +241 -0
  56. data/spec/suites/rspec_2/functional/proxy_spec.rb +136 -0
  57. data/spec/suites/rspec_2/functional/spy_spec.rb +41 -0
  58. data/spec/suites/rspec_2/functional/strong_spec.rb +79 -0
  59. data/spec/suites/rspec_2/functional/stub_spec.rb +190 -0
  60. data/spec/suites/rspec_2/functional/wildcard_matchers_spec.rb +128 -0
  61. data/spec/suites/rspec_2/integration/minitest_rails_spec.rb +15 -0
  62. data/spec/suites/rspec_2/integration/rspec_2_spec.rb +20 -0
  63. data/spec/suites/rspec_2/integration/test_unit_rails_spec.rb +14 -0
  64. data/spec/suites/rspec_2/spec_helper.rb +27 -0
  65. data/spec/suites/rspec_2/support/matchers/wildcard_matcher_matchers.rb +32 -0
  66. data/spec/suites/rspec_2/support/shared_examples/space.rb +13 -0
  67. data/spec/suites/rspec_2/support/shared_examples/times_called_expectation.rb +9 -0
  68. data/spec/suites/rspec_2/unit/adapters/rr_methods/double_creators_spec.rb +135 -0
  69. data/spec/suites/rspec_2/unit/adapters/rr_methods/space_spec.rb +101 -0
  70. data/spec/suites/rspec_2/unit/adapters/rr_methods/wildcard_matchers_spec.rb +69 -0
  71. data/spec/suites/rspec_2/unit/adapters/rspec/invocation_matcher_spec.rb +297 -0
  72. data/spec/suites/rspec_2/unit/adapters/rspec_spec.rb +85 -0
  73. data/spec/suites/rspec_2/unit/core_ext/array_spec.rb +39 -0
  74. data/spec/suites/rspec_2/unit/core_ext/enumerable_spec.rb +81 -0
  75. data/spec/suites/rspec_2/unit/core_ext/hash_spec.rb +55 -0
  76. data/spec/suites/rspec_2/unit/core_ext/range_spec.rb +41 -0
  77. data/spec/suites/rspec_2/unit/core_ext/regexp_spec.rb +41 -0
  78. data/spec/suites/rspec_2/unit/double_definitions/child_double_definition_create_spec.rb +114 -0
  79. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_blank_slate_spec.rb +93 -0
  80. data/spec/suites/rspec_2/unit/double_definitions/double_definition_create_spec.rb +446 -0
  81. data/spec/suites/rspec_2/unit/errors/rr_error_spec.rb +67 -0
  82. data/spec/suites/rspec_2/unit/expectations/any_argument_expectation_spec.rb +48 -0
  83. data/spec/suites/rspec_2/unit/expectations/anything_argument_equality_expectation_spec.rb +14 -0
  84. data/spec/suites/rspec_2/unit/expectations/argument_equality_expectation_spec.rb +135 -0
  85. data/spec/suites/rspec_2/unit/expectations/boolean_argument_equality_expectation_spec.rb +30 -0
  86. data/spec/suites/rspec_2/unit/expectations/hash_including_argument_equality_expectation_spec.rb +82 -0
  87. data/spec/suites/rspec_2/unit/expectations/satisfy_argument_equality_expectation_spec.rb +61 -0
  88. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/any_times_matcher_spec.rb +22 -0
  89. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_least_matcher_spec.rb +37 -0
  90. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/at_most_matcher_spec.rb +43 -0
  91. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/integer_matcher_spec.rb +58 -0
  92. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/proc_matcher_spec.rb +35 -0
  93. data/spec/suites/rspec_2/unit/expectations/times_called_expectation/range_matcher_spec.rb +39 -0
  94. data/spec/suites/rspec_2/unit/hash_with_object_id_key_spec.rb +88 -0
  95. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_spec.rb +545 -0
  96. data/spec/suites/rspec_2/unit/injections/double_injection/double_injection_verify_spec.rb +32 -0
  97. data/spec/suites/rspec_2/unit/proc_from_block_spec.rb +14 -0
  98. data/spec/suites/rspec_2/unit/rr_spec.rb +28 -0
  99. data/spec/suites/rspec_2/unit/space_spec.rb +595 -0
  100. data/spec/suites/rspec_2/unit/spy_verification_spec.rb +133 -0
  101. data/spec/suites/rspec_2/unit/times_called_matchers/any_times_matcher_spec.rb +46 -0
  102. data/spec/suites/rspec_2/unit/times_called_matchers/at_least_matcher_spec.rb +54 -0
  103. data/spec/suites/rspec_2/unit/times_called_matchers/at_most_matcher_spec.rb +69 -0
  104. data/spec/suites/rspec_2/unit/times_called_matchers/integer_matcher_spec.rb +69 -0
  105. data/spec/suites/rspec_2/unit/times_called_matchers/proc_matcher_spec.rb +54 -0
  106. data/spec/suites/rspec_2/unit/times_called_matchers/range_matcher_spec.rb +75 -0
  107. data/spec/suites/rspec_2/unit/times_called_matchers/times_called_matcher_spec.rb +117 -0
  108. data/spec/suites/rspec_2/unit/wildcard_matchers/anything_spec.rb +33 -0
  109. data/spec/suites/rspec_2/unit/wildcard_matchers/boolean_spec.rb +45 -0
  110. data/spec/suites/rspec_2/unit/wildcard_matchers/duck_type_spec.rb +64 -0
  111. data/spec/suites/rspec_2/unit/wildcard_matchers/hash_including_spec.rb +64 -0
  112. data/spec/suites/rspec_2/unit/wildcard_matchers/is_a_spec.rb +55 -0
  113. data/spec/suites/rspec_2/unit/wildcard_matchers/numeric_spec.rb +46 -0
  114. data/spec/suites/rspec_2/unit/wildcard_matchers/satisfy_spec.rb +57 -0
  115. data/spec/suites/test_unit_1/integration/test_unit_1_test.rb +6 -0
  116. data/spec/suites/test_unit_1/test_helper.rb +7 -0
  117. data/spec/suites/test_unit_2/integration/test_unit_2_test.rb +6 -0
  118. data/spec/suites/test_unit_2/test_helper.rb +3 -0
  119. metadata +183 -19
  120. data/Gemfile +0 -9
  121. data/Rakefile +0 -34
  122. data/lib/rr/adapters/rspec2.rb +0 -30
  123. data/lib/rr/adapters/test_unit.rb +0 -33
  124. data/lib/rr/errors/argument_equality_error.rb +0 -6
  125. data/lib/rr/wildcard_matchers/range.rb +0 -7
  126. data/lib/rr/wildcard_matchers/regexp.rb +0 -7
  127. data/spec/runner.rb +0 -41
@@ -0,0 +1,297 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../../spec_helper")
2
+
3
+ module RR
4
+ module Adapters
5
+ module RSpec
6
+ describe InvocationMatcher do
7
+ describe "matching against a method with no doubles" do
8
+ before do
9
+ @matcher = InvocationMatcher.new(:foobar)
10
+ @result = @matcher.matches?(Object.new)
11
+ end
12
+
13
+ it "does not match" do
14
+ @result.should_not be
15
+ end
16
+ end
17
+
18
+ describe "defining an expectation using a method invocation" do
19
+ subject { Object.new }
20
+
21
+ before do
22
+ stub(subject).foobar
23
+ subject.foobar(:args)
24
+ @result = InvocationMatcher.new.foobar(:args).matches?(subject)
25
+ end
26
+
27
+ it "uses the invoked method as the expected method" do
28
+ expect(@result).to be
29
+ end
30
+ end
31
+
32
+ describe "matching against a stubbed method that was never called" do
33
+ subject { Object.new }
34
+
35
+ before do
36
+ stub(subject).foobar
37
+ @matcher = InvocationMatcher.new(:foobar)
38
+ @result = @matcher.matches?(subject)
39
+ end
40
+
41
+ it "does not match" do
42
+ @result.should_not be
43
+ end
44
+ end
45
+
46
+ describe "matching against a stubbed method that was called once" do
47
+ subject { Object.new }
48
+
49
+ before do
50
+ stub(subject).foobar
51
+ subject.foobar
52
+ @result = InvocationMatcher.new(:foobar).matches?(subject)
53
+ end
54
+
55
+ it "does match" do
56
+ expect(@result).to be
57
+ end
58
+ end
59
+
60
+ describe "matching against a stubbed method that was called with unexpected arguments" do
61
+ subject { Object.new }
62
+
63
+ before do
64
+ @args = %w(one two)
65
+ stub(subject).foobar
66
+ subject.foobar(:other)
67
+ @result = InvocationMatcher.new(:foobar).with(*@args).matches?(subject)
68
+ end
69
+
70
+ it "does not match" do
71
+ @result.should_not be
72
+ end
73
+ end
74
+
75
+ describe "matching against a stubbed method that was called with expected arguments" do
76
+ subject { Object.new }
77
+
78
+ before do
79
+ @args = %w(one two)
80
+ stub(subject).foobar
81
+ subject.foobar(*@args)
82
+ @result = InvocationMatcher.new(:foobar).with(*@args).matches?(subject)
83
+ end
84
+
85
+ it "does match" do
86
+ expect(@result).to be
87
+ end
88
+ end
89
+
90
+ describe "defining a fulfilled argument expectation using a method invocation" do
91
+ subject { Object.new }
92
+
93
+ before do
94
+ @args = %w(one two)
95
+ stub(subject).foobar
96
+ subject.foobar(*@args)
97
+ @result = InvocationMatcher.new.foobar(*@args).matches?(subject)
98
+ end
99
+
100
+ it "does match" do
101
+ expect(@result).to be
102
+ end
103
+ end
104
+
105
+ describe "defining an unfulfilled argument expectation using a method invocation" do
106
+ subject { Object.new }
107
+
108
+ before do
109
+ @args = %w(one two)
110
+ stub(subject).foobar
111
+ subject.foobar(:other)
112
+ @result = InvocationMatcher.new.foobar(*@args).matches?(subject)
113
+ end
114
+
115
+ it "does not match" do
116
+ @result.should_not be
117
+ end
118
+ end
119
+
120
+ describe "matching against a stubbed method that was called more than once" do
121
+ subject { Object.new }
122
+
123
+ before do
124
+ stub(subject).foobar
125
+ 2.times { subject.foobar }
126
+ @result = InvocationMatcher.new(:foobar).twice.matches?(subject)
127
+ end
128
+
129
+ it "does match" do
130
+ expect(@result).to be
131
+ end
132
+ end
133
+
134
+ describe "matching a stubbed method with any arguments" do
135
+ subject { Object.new }
136
+
137
+ before do
138
+ stub(subject).foobar
139
+ subject.foobar(:args)
140
+ @result = InvocationMatcher.new(:foobar).with_any_args.matches?(subject)
141
+ end
142
+
143
+ it "does match" do
144
+ expect(@result).to be
145
+ end
146
+ end
147
+
148
+ describe "matching a stubbed method with no arguments when arguments are not provided" do
149
+ subject { Object.new }
150
+
151
+ before do
152
+ stub(subject).foobar
153
+ subject.foobar
154
+ @result = InvocationMatcher.new(:foobar).with_no_args.matches?(subject)
155
+ end
156
+
157
+ it "does match" do
158
+ expect(@result).to be
159
+ end
160
+ end
161
+
162
+ describe "matching a stubbed method with no arguments when arguments are provided" do
163
+ subject { Object.new }
164
+
165
+ before do
166
+ stub(subject).foobar
167
+ subject.foobar(:args)
168
+ @result = InvocationMatcher.new(:foobar).with_no_args.matches?(subject)
169
+ end
170
+
171
+ it "does not match" do
172
+ @result.should_not be
173
+ end
174
+ end
175
+
176
+ describe "matching a method that was called twice when expected once" do
177
+ subject { Object.new }
178
+
179
+ before do
180
+ stub(subject).foobar
181
+ 2.times { subject.foobar }
182
+ @matcher = InvocationMatcher.new(:foobar).times(1)
183
+ @result = @matcher.matches?(subject)
184
+ end
185
+
186
+ it "does not match" do
187
+ @result.should_not be
188
+ end
189
+ end
190
+
191
+ describe "matching a method that was called twice when expected twice" do
192
+ subject { Object.new }
193
+
194
+ before do
195
+ stub(subject).foobar
196
+ 2.times { subject.foobar }
197
+ @result = InvocationMatcher.new(:foobar).times(2).matches?(subject)
198
+ end
199
+
200
+ it "does match" do
201
+ expect(@result).to be
202
+ end
203
+ end
204
+
205
+ describe "matching a method that was called twice when any number of times" do
206
+ subject { Object.new }
207
+
208
+ before do
209
+ stub(subject).foobar
210
+ 2.times { subject.foobar }
211
+ @result = InvocationMatcher.new(:foobar).any_number_of_times.matches?(subject)
212
+ end
213
+
214
+ it "does match" do
215
+ expect(@result).to be
216
+ end
217
+ end
218
+
219
+ describe "matching a method that was called three times when expected at most twice" do
220
+ subject { Object.new }
221
+
222
+ before do
223
+ stub(subject).foobar
224
+ 3.times { subject.foobar }
225
+ @result = InvocationMatcher.new(:foobar).at_most(2).matches?(subject)
226
+ end
227
+
228
+ it "does not match" do
229
+ @result.should_not be
230
+ end
231
+ end
232
+
233
+ describe "matching a method that was called once when expected at most twice" do
234
+ subject { Object.new }
235
+
236
+ before do
237
+ stub(subject).foobar
238
+ subject.foobar
239
+ @result = InvocationMatcher.new(:foobar).at_most(2).matches?(subject)
240
+ end
241
+
242
+ it "does match" do
243
+ expect(@result).to be
244
+ end
245
+ end
246
+
247
+ describe "matching a method that was called once when expected at least twice" do
248
+ subject { Object.new }
249
+
250
+ before do
251
+ stub(subject).foobar
252
+ subject.foobar
253
+ @result = InvocationMatcher.new(:foobar).at_least(2).matches?(subject)
254
+ end
255
+
256
+ it "does not match" do
257
+ @result.should_not be
258
+ end
259
+ end
260
+
261
+ describe "matching a method that was called three times when expected at least twice" do
262
+ subject { Object.new }
263
+
264
+ before do
265
+ stub(subject).foobar
266
+ 3.times { subject.foobar }
267
+ @result = InvocationMatcher.new(:foobar).at_least(2).matches?(subject)
268
+ end
269
+
270
+ it "does match" do
271
+ expect(@result).to be
272
+ end
273
+ end
274
+
275
+ describe "that does not match" do
276
+ before do
277
+ @error = Object.new
278
+ @message = 'Verification error message'
279
+ stub(RR::Space.instance.recorded_calls).match_error { @error }
280
+ stub(@error).message { @message }
281
+
282
+ @matcher = InvocationMatcher.new(:foobar)
283
+ @result = @matcher.matches?(Object.new)
284
+ end
285
+
286
+ it "returns false when matching" do
287
+ @result.should_not be
288
+ end
289
+
290
+ it "returns a failure messsage" do
291
+ expect(@matcher.failure_message).to eq @message
292
+ end
293
+ end
294
+ end
295
+ end
296
+ end
297
+ end
@@ -0,0 +1,85 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
2
+
3
+ module RR
4
+ module Adapters
5
+ describe RSpec1 do
6
+ attr_reader :fixture, :method_name
7
+
8
+ describe "#setup_mocks_for_rspec" do
9
+ subject { Object.new }
10
+
11
+ before do
12
+ @fixture = Object.new
13
+ fixture.extend RSpec1::AdapterMethods
14
+ @method_name = :foobar
15
+ end
16
+
17
+ it "resets the double_injections" do
18
+ stub(subject).foobar
19
+ ::RR::Injections::DoubleInjection.instances.should_not be_empty
20
+
21
+ fixture.setup_mocks_for_rspec
22
+ expect(::RR::Injections::DoubleInjection.instances).to be_empty
23
+ end
24
+ end
25
+
26
+ describe "#verify_mocks_for_rspec" do
27
+ subject { Object.new }
28
+
29
+ before do
30
+ @fixture = Object.new
31
+ fixture.extend RSpec1::AdapterMethods
32
+ @method_name = :foobar
33
+ end
34
+
35
+ it "verifies the double_injections" do
36
+ mock(subject).foobar
37
+
38
+ expect {
39
+ fixture.verify_mocks_for_rspec
40
+ }.to raise_error(::RR::Errors::TimesCalledError)
41
+ expect(::RR::Injections::DoubleInjection.instances).to be_empty
42
+ end
43
+ end
44
+
45
+ describe "#teardown_mocks_for_rspec" do
46
+ subject { Object.new }
47
+
48
+ before do
49
+ @fixture = Object.new
50
+ fixture.extend RSpec1::AdapterMethods
51
+ @method_name = :foobar
52
+ end
53
+
54
+ it "resets the double_injections" do
55
+ stub(subject).foobar
56
+ ::RR::Injections::DoubleInjection.instances.should_not be_empty
57
+
58
+ fixture.teardown_mocks_for_rspec
59
+ expect(::RR::Injections::DoubleInjection.instances).to be_empty
60
+ end
61
+ end
62
+
63
+ describe "#trim_backtrace" do
64
+ it "does not set trim_backtrace" do
65
+ expect(RR.trim_backtrace).to eq false
66
+ end
67
+ end
68
+
69
+ describe '#have_received' do
70
+ it "creates an invocation matcher with a method name" do
71
+ method = :test
72
+ matcher = 'fake'
73
+ mock(RR::Adapters::RSpec::InvocationMatcher).new(method) { matcher }
74
+ expect(have_received(method)).to eq matcher
75
+ end
76
+
77
+ it "creates an invocation matcher without a method name" do
78
+ matcher = 'fake'
79
+ mock(RR::Adapters::RSpec::InvocationMatcher).new(nil) { matcher }
80
+ expect(have_received).to eq matcher
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe Array do
4
+ include WildcardMatcherMatchers
5
+
6
+ describe '#wildcard_match?' do
7
+ context 'when this Array has items that respond to #wildcard_match?' do
8
+ subject { [hash_including({:foo => 'bar'})] }
9
+
10
+ it "returns true if all items in the given Array wildcard-match corresponding items in this Array" do
11
+ should wildcard_match([{:foo => 'bar', :baz => 'quux'}])
12
+ end
13
+
14
+ it "returns true if any items in the given Array do not wildcard-match corresponding items in this Array" do
15
+ should_not wildcard_match([{:foo => 'bat', :baz => 'quux'}])
16
+ end
17
+ end
18
+
19
+ context 'when this Array has items that do not respond to #wildcard_match?' do
20
+ subject { [:a_symbol] }
21
+
22
+ it "returns true if all items in the given Array equal-match corresponding items in this Array" do
23
+ should wildcard_match([:a_symbol])
24
+ end
25
+
26
+ it "returns true if any items in the given Array do not equal-match corresponding items in this Array" do
27
+ should_not wildcard_match([:another_symbol])
28
+ end
29
+ end
30
+
31
+ context 'when not given an Array' do
32
+ subject { [{:foo => 'bar'}] }
33
+
34
+ it "returns false" do
35
+ should_not wildcard_match(:something_else)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,81 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe Enumerable do
4
+ include WildcardMatcherMatchers
5
+
6
+ let(:klass) {
7
+ Class.new do
8
+ include Enumerable
9
+
10
+ def initialize(*items)
11
+ @arr = items
12
+ end
13
+
14
+ def each(&block)
15
+ @arr.each(&block)
16
+ end
17
+ end
18
+ }
19
+
20
+ describe '#wildcard_match?' do
21
+ context 'when this Enumerable has items that respond to #wildcard_match?' do
22
+ subject { klass.new(hash_including({:foo => 'bar'})) }
23
+
24
+ it "returns true if all items in the given Enumerable wildcard-match corresponding items in this Enumerable" do
25
+ should wildcard_match([{:foo => 'bar', :baz => 'quux'}])
26
+ end
27
+
28
+ it "returns true if any items in the given Enumerable do not wildcard-match corresponding items in this Enumerable" do
29
+ should_not wildcard_match([{:foo => 'bat', :baz => 'quux'}])
30
+ end
31
+ end
32
+
33
+ context 'when this Enumerable has items that do not respond to #wildcard_match?' do
34
+ subject { klass.new(:a_symbol) }
35
+
36
+ it "returns true if all items in the given Enumerable equal-match corresponding items in this Enumerable" do
37
+ should wildcard_match([:a_symbol])
38
+ end
39
+
40
+ it "returns true if any items in the given Enumerable do not equal-match corresponding items in this Enumerable" do
41
+ should_not wildcard_match([:another_symbol])
42
+ end
43
+ end
44
+
45
+ if RUBY_VERSION =~ /^1.8/
46
+ context 'when the Enumerable is a String' do
47
+ subject { 'foo' }
48
+
49
+ it "returns true if the String is exactly equal to the given String" do
50
+ should wildcard_match('foo')
51
+ end
52
+
53
+ it "returns false if the string is not exactly equal to the given String" do
54
+ should_not wildcard_match('bar')
55
+ end
56
+
57
+ context 'whose #== method has been proxied' do
58
+ before do
59
+ @r1 = 'x'
60
+ @r2 = 'y'
61
+ mock.proxy(@r1) == @r1
62
+ mock.proxy(@r1) == @r2
63
+ end
64
+
65
+ it "doesn't blow up with a recursive loop error" do
66
+ @r1 == @r1
67
+ @r1 == @r2
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ context 'when not given an Enumerable' do
74
+ subject { klass.new({:foo => 'bar'}) }
75
+
76
+ it "returns false" do
77
+ should_not wildcard_match(:something_else)
78
+ end
79
+ end
80
+ end
81
+ end