rspec-expectations 3.0.0.beta2 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -2
  4. data/.yardopts +0 -1
  5. data/Changelog.md +115 -35
  6. data/README.md +2 -2
  7. data/lib/rspec/expectations.rb +13 -8
  8. data/lib/rspec/{matchers → expectations}/configuration.rb +38 -13
  9. data/lib/rspec/expectations/expectation_target.rb +72 -8
  10. data/lib/rspec/expectations/fail_with.rb +10 -52
  11. data/lib/rspec/expectations/handler.rb +9 -11
  12. data/lib/rspec/expectations/syntax.rb +37 -35
  13. data/lib/rspec/expectations/version.rb +1 -1
  14. data/lib/rspec/matchers.rb +60 -9
  15. data/lib/rspec/matchers/aliased_matcher.rb +6 -0
  16. data/lib/rspec/matchers/built_in.rb +9 -1
  17. data/lib/rspec/matchers/built_in/all.rb +78 -0
  18. data/lib/rspec/matchers/built_in/base_matcher.rb +39 -1
  19. data/lib/rspec/matchers/built_in/be.rb +117 -42
  20. data/lib/rspec/matchers/built_in/be_between.rb +22 -0
  21. data/lib/rspec/matchers/built_in/be_instance_of.rb +11 -3
  22. data/lib/rspec/matchers/built_in/be_kind_of.rb +5 -0
  23. data/lib/rspec/matchers/built_in/be_within.rb +26 -6
  24. data/lib/rspec/matchers/built_in/change.rb +89 -13
  25. data/lib/rspec/matchers/built_in/compound.rb +19 -3
  26. data/lib/rspec/matchers/built_in/contain_exactly.rb +17 -6
  27. data/lib/rspec/matchers/built_in/cover.rb +3 -0
  28. data/lib/rspec/matchers/built_in/eq.rb +20 -5
  29. data/lib/rspec/matchers/built_in/eql.rb +15 -3
  30. data/lib/rspec/matchers/built_in/equal.rb +23 -6
  31. data/lib/rspec/matchers/built_in/exist.rb +74 -10
  32. data/lib/rspec/matchers/built_in/has.rb +58 -3
  33. data/lib/rspec/matchers/built_in/include.rb +16 -1
  34. data/lib/rspec/matchers/built_in/match.rb +14 -4
  35. data/lib/rspec/matchers/built_in/operators.rb +16 -0
  36. data/lib/rspec/matchers/built_in/output.rb +47 -5
  37. data/lib/rspec/matchers/built_in/raise_error.rb +40 -23
  38. data/lib/rspec/matchers/built_in/respond_to.rb +37 -16
  39. data/lib/rspec/matchers/built_in/satisfy.rb +15 -0
  40. data/lib/rspec/matchers/built_in/start_and_end_with.rb +29 -14
  41. data/lib/rspec/matchers/built_in/throw_symbol.rb +32 -3
  42. data/lib/rspec/matchers/built_in/yield.rb +148 -44
  43. data/lib/rspec/matchers/composable.rb +48 -7
  44. data/lib/rspec/matchers/dsl.rb +45 -17
  45. data/lib/rspec/matchers/generated_descriptions.rb +7 -0
  46. data/lib/rspec/matchers/matcher_delegator.rb +6 -2
  47. data/lib/rspec/matchers/pretty.rb +15 -19
  48. metadata +33 -236
  49. metadata.gz.sig +0 -0
  50. data/features/README.md +0 -48
  51. data/features/Upgrade.md +0 -53
  52. data/features/built_in_matchers/README.md +0 -96
  53. data/features/built_in_matchers/be.feature +0 -175
  54. data/features/built_in_matchers/be_within.feature +0 -48
  55. data/features/built_in_matchers/comparisons.feature +0 -97
  56. data/features/built_in_matchers/contain_exactly.feature +0 -46
  57. data/features/built_in_matchers/cover.feature +0 -47
  58. data/features/built_in_matchers/end_with.feature +0 -48
  59. data/features/built_in_matchers/equality.feature +0 -136
  60. data/features/built_in_matchers/exist.feature +0 -45
  61. data/features/built_in_matchers/expect_change.feature +0 -59
  62. data/features/built_in_matchers/expect_error.feature +0 -144
  63. data/features/built_in_matchers/include.feature +0 -126
  64. data/features/built_in_matchers/match.feature +0 -51
  65. data/features/built_in_matchers/output.feature +0 -70
  66. data/features/built_in_matchers/predicates.feature +0 -161
  67. data/features/built_in_matchers/respond_to.feature +0 -84
  68. data/features/built_in_matchers/satisfy.feature +0 -33
  69. data/features/built_in_matchers/start_with.feature +0 -48
  70. data/features/built_in_matchers/throw_symbol.feature +0 -91
  71. data/features/built_in_matchers/types.feature +0 -116
  72. data/features/built_in_matchers/yield.feature +0 -161
  73. data/features/composing_matchers.feature +0 -250
  74. data/features/compound_expectations.feature +0 -45
  75. data/features/custom_matchers/access_running_example.feature +0 -53
  76. data/features/custom_matchers/define_diffable_matcher.feature +0 -27
  77. data/features/custom_matchers/define_matcher.feature +0 -340
  78. data/features/custom_matchers/define_matcher_outside_rspec.feature +0 -34
  79. data/features/custom_matchers/define_matcher_with_fluent_interface.feature +0 -24
  80. data/features/customized_message.feature +0 -39
  81. data/features/diffing.feature +0 -85
  82. data/features/implicit_docstrings.feature +0 -52
  83. data/features/step_definitions/additional_cli_steps.rb +0 -22
  84. data/features/support/env.rb +0 -21
  85. data/features/support/rubinius.rb +0 -6
  86. data/features/syntax_configuration.feature +0 -71
  87. data/features/test_frameworks/minitest.feature +0 -44
  88. data/lib/rspec-expectations.rb +0 -1
  89. data/lib/rspec/expectations/diff_presenter.rb +0 -141
  90. data/lib/rspec/expectations/differ.rb +0 -44
  91. data/lib/rspec/expectations/encoded_string.rb +0 -56
  92. data/spec/rspec/expectations/diff_presenter_spec.rb +0 -249
  93. data/spec/rspec/expectations/encoded_string_spec.rb +0 -74
  94. data/spec/rspec/expectations/expectation_target_spec.rb +0 -82
  95. data/spec/rspec/expectations/extensions/kernel_spec.rb +0 -67
  96. data/spec/rspec/expectations/fail_with_spec.rb +0 -114
  97. data/spec/rspec/expectations/handler_spec.rb +0 -205
  98. data/spec/rspec/expectations/minitest_integration_spec.rb +0 -27
  99. data/spec/rspec/expectations/syntax_spec.rb +0 -89
  100. data/spec/rspec/expectations_spec.rb +0 -12
  101. data/spec/rspec/matchers/aliased_matcher_spec.rb +0 -48
  102. data/spec/rspec/matchers/aliases_spec.rb +0 -449
  103. data/spec/rspec/matchers/built_in/base_matcher_spec.rb +0 -83
  104. data/spec/rspec/matchers/built_in/be_between_spec.rb +0 -159
  105. data/spec/rspec/matchers/built_in/be_instance_of_spec.rb +0 -63
  106. data/spec/rspec/matchers/built_in/be_kind_of_spec.rb +0 -41
  107. data/spec/rspec/matchers/built_in/be_spec.rb +0 -592
  108. data/spec/rspec/matchers/built_in/be_within_spec.rb +0 -141
  109. data/spec/rspec/matchers/built_in/change_spec.rb +0 -808
  110. data/spec/rspec/matchers/built_in/compound_spec.rb +0 -292
  111. data/spec/rspec/matchers/built_in/contain_exactly_spec.rb +0 -441
  112. data/spec/rspec/matchers/built_in/cover_spec.rb +0 -69
  113. data/spec/rspec/matchers/built_in/eq_spec.rb +0 -156
  114. data/spec/rspec/matchers/built_in/eql_spec.rb +0 -41
  115. data/spec/rspec/matchers/built_in/equal_spec.rb +0 -106
  116. data/spec/rspec/matchers/built_in/exist_spec.rb +0 -124
  117. data/spec/rspec/matchers/built_in/has_spec.rb +0 -161
  118. data/spec/rspec/matchers/built_in/include_spec.rb +0 -540
  119. data/spec/rspec/matchers/built_in/match_spec.rb +0 -102
  120. data/spec/rspec/matchers/built_in/operators_spec.rb +0 -252
  121. data/spec/rspec/matchers/built_in/output_spec.rb +0 -165
  122. data/spec/rspec/matchers/built_in/raise_error_spec.rb +0 -461
  123. data/spec/rspec/matchers/built_in/respond_to_spec.rb +0 -292
  124. data/spec/rspec/matchers/built_in/satisfy_spec.rb +0 -44
  125. data/spec/rspec/matchers/built_in/start_and_end_with_spec.rb +0 -253
  126. data/spec/rspec/matchers/built_in/throw_symbol_spec.rb +0 -135
  127. data/spec/rspec/matchers/built_in/yield_spec.rb +0 -627
  128. data/spec/rspec/matchers/configuration_spec.rb +0 -213
  129. data/spec/rspec/matchers/description_generation_spec.rb +0 -191
  130. data/spec/rspec/matchers/dsl_spec.rb +0 -895
  131. data/spec/rspec/matchers/legacy_spec.rb +0 -101
  132. data/spec/rspec/matchers_spec.rb +0 -74
  133. data/spec/spec_helper.rb +0 -85
  134. data/spec/support/matchers.rb +0 -22
  135. data/spec/support/shared_examples.rb +0 -35
@@ -1,12 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- describe Expectations do
5
- it 'does not allow expectation failures to be caught by a bare rescue' do
6
- expect {
7
- expect(2).to eq(3) rescue nil
8
- }.to fail_matching("expected: 3")
9
- end
10
- end
11
- end
12
-
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Matchers
5
- describe AliasedMatcher do
6
- RSpec::Matchers.define :my_base_matcher do
7
- def foo
8
- 13
9
- end
10
-
11
- def description
12
- "my base matcher description"
13
- end
14
- end
15
-
16
- it 'can get a method object for delegated methods', :if => (RUBY_VERSION.to_f > 1.8) do
17
- matcher = my_base_matcher
18
- decorated = AliasedMatcher.new(matcher, Proc.new { })
19
-
20
- expect(decorated.method(:foo).call).to eq(13)
21
- end
22
-
23
- it 'can get a method object for `description`' do
24
- matcher = my_base_matcher
25
- decorated = AliasedMatcher.new(matcher, Proc.new { "overriden description" })
26
-
27
- expect(decorated.method(:description).call).to eq("overriden description")
28
- end
29
-
30
- RSpec::Matchers.alias_matcher :my_overriden_matcher, :my_base_matcher do |desc|
31
- desc + " (overriden)"
32
- end
33
-
34
- it 'overrides the description with the provided block' do
35
- matcher = my_overriden_matcher
36
- expect(matcher.description).to eq("my base matcher description (overriden)")
37
- end
38
-
39
- RSpec::Matchers.alias_matcher :my_blockless_override, :my_base_matcher
40
-
41
- it 'provides a default description override based on the old and new games' do
42
- matcher = my_blockless_override
43
- expect(matcher.description).to eq("my blockless override description")
44
- end
45
- end
46
- end
47
- end
48
-
@@ -1,449 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- describe Matchers, "aliases", :order => :defined do
5
- matcher :be_aliased_to do |old_matcher|
6
- chain :with_description do |desc|
7
- @expected_desc = desc
8
- end
9
-
10
- match do |aliased_matcher|
11
- @actual_desc = aliased_matcher.description
12
-
13
- @actual_desc == @expected_desc &&
14
- aliased_matcher.base_matcher.class == old_matcher.class
15
- end
16
-
17
- failure_message do |aliased_matcher|
18
- "expected #{aliased_matcher} to be aliased to #{old_matcher} with " +
19
- "description: #{@expected_desc.inspect}, but got #{@actual_desc.inspect}"
20
- end
21
-
22
- description do |aliased_matcher|
23
- "have an alias for #{old_matcher.description.inspect} with description: #{@expected_desc.inspect}"
24
- end
25
- end
26
-
27
- specify do
28
- expect(a_truthy_value).to be_aliased_to(be_truthy).with_description("a truthy value")
29
- end
30
-
31
- specify do
32
- expect(a_falsey_value).to be_aliased_to(be_falsey).with_description("a falsey value")
33
- end
34
-
35
- specify do
36
- expect(be_falsy).to be_aliased_to(be_falsey).with_description("be falsy")
37
- end
38
-
39
- specify do
40
- expect(a_falsy_value).to be_aliased_to(be_falsey).with_description("a falsy value")
41
- end
42
-
43
- specify do
44
- expect(a_nil_value).to be_aliased_to(be_nil).with_description("a nil value")
45
- end
46
-
47
- specify do
48
- expect(a_value > 3).to be_aliased_to(be > 3).with_description("a value > 3")
49
- end
50
-
51
- specify do
52
- expect(a_value < 3).to be_aliased_to(be < 3).with_description("a value < 3")
53
- end
54
-
55
- specify do
56
- expect(a_value <= 3).to be_aliased_to(be <= 3).with_description("a value <= 3")
57
- end
58
-
59
- specify do
60
- expect(a_value == 3).to be_aliased_to(be == 3).with_description("a value == 3")
61
- end
62
-
63
- specify do
64
- expect(a_value === 3).to be_aliased_to(be === 3).with_description("a value === 3")
65
- end
66
-
67
- specify do
68
- expect(
69
- an_instance_of(Integer)
70
- ).to be_aliased_to(
71
- be_an_instance_of(Integer)
72
- ).with_description("an instance of Integer")
73
- end
74
-
75
- specify do
76
- expect(
77
- a_kind_of(Integer)
78
- ).to be_aliased_to(
79
- be_a_kind_of(Integer)
80
- ).with_description("a kind of Integer")
81
- end
82
-
83
- specify do
84
- expect(
85
- a_value_between(1, 10)
86
- ).to be_aliased_to(
87
- be_between(1, 10)
88
- ).with_description("a value between 1 and 10 (inclusive)")
89
- end
90
-
91
- specify do
92
- expect(
93
- a_value_within(0.1).of(3)
94
- ).to be_aliased_to(
95
- be_within(0.1).of(3)
96
- ).with_description("a value within 0.1 of 3")
97
- end
98
-
99
- specify do
100
- expect(
101
- within(0.1).of(3)
102
- ).to be_aliased_to(
103
- be_within(0.1).of(3)
104
- ).with_description("within 0.1 of 3")
105
- end
106
-
107
- specify do
108
- expect(a_block_changing).to be_aliased_to(change).with_description("a block changing result")
109
- end
110
-
111
- specify do
112
- expect(changing).to be_aliased_to(change).with_description("changing result")
113
- end
114
-
115
- specify do
116
- expect(
117
- a_collection_containing_exactly(1, 2)
118
- ).to be_aliased_to(
119
- contain_exactly(1, 2)
120
- ).with_description("a collection containing exactly 1 and 2")
121
- end
122
-
123
- specify do
124
- expect(
125
- containing_exactly(1, 2)
126
- ).to be_aliased_to(
127
- contain_exactly(1, 2)
128
- ).with_description("containing exactly 1 and 2")
129
- end
130
-
131
- specify do
132
- expect(
133
- a_range_covering(1, 2)
134
- ).to be_aliased_to(
135
- cover(1, 2)
136
- ).with_description("a range covering 1 and 2")
137
- end
138
-
139
- specify do
140
- expect(
141
- covering(1, 2)
142
- ).to be_aliased_to(
143
- cover(1, 2)
144
- ).with_description("covering 1 and 2")
145
- end
146
-
147
- specify do
148
- expect(
149
- ending_with(23)
150
- ).to be_aliased_to(
151
- end_with(23)
152
- ).with_description("ending with 23")
153
- end
154
-
155
- specify do
156
- expect(
157
- a_collection_ending_with(23)
158
- ).to be_aliased_to(
159
- end_with(23)
160
- ).with_description("a collection ending with 23")
161
- end
162
-
163
- specify do
164
- expect(
165
- a_string_ending_with("z")
166
- ).to be_aliased_to(
167
- end_with("z")
168
- ).with_description('a string ending with "z"')
169
- end
170
-
171
- specify do
172
- expect(
173
- an_object_eq_to(3)
174
- ).to be_aliased_to(eq 3).with_description("an object eq to 3")
175
- end
176
-
177
- specify do
178
- expect(
179
- eq_to(3)
180
- ).to be_aliased_to(eq 3).with_description("eq to 3")
181
- end
182
-
183
- specify do
184
- expect(
185
- an_object_eql_to(3)
186
- ).to be_aliased_to(eql 3).with_description("an object eql to 3")
187
- end
188
-
189
- specify do
190
- expect(
191
- eql_to(3)
192
- ).to be_aliased_to(eql 3).with_description("eql to 3")
193
- end
194
-
195
- specify do
196
- expect(
197
- an_object_equal_to(3)
198
- ).to be_aliased_to(equal 3).with_description("an object equal to 3")
199
- end
200
-
201
- specify do
202
- expect(
203
- equal_to(3)
204
- ).to be_aliased_to(equal 3).with_description("equal to 3")
205
- end
206
-
207
- specify do
208
- expect(
209
- an_object_existing
210
- ).to be_aliased_to(exist).with_description("an object existing")
211
- end
212
-
213
- specify do
214
- expect(existing).to be_aliased_to(exist).with_description("existing")
215
- end
216
-
217
- specify do
218
- expect(
219
- a_string_including("a")
220
- ).to be_aliased_to(
221
- include("a")
222
- ).with_description('a string including "a"')
223
- end
224
-
225
- specify do
226
- expect(
227
- a_collection_including("a")
228
- ).to be_aliased_to(
229
- include("a")
230
- ).with_description('a collection including "a"')
231
- end
232
-
233
- specify do
234
- expect(
235
- a_hash_including(:a => 5)
236
- ).to be_aliased_to(
237
- include(:a => 5)
238
- ).with_description('a hash including {:a => 5}')
239
- end
240
-
241
- specify do
242
- expect(
243
- including(3)
244
- ).to be_aliased_to(
245
- include(3)
246
- ).with_description('including 3')
247
- end
248
-
249
- specify do
250
- expect(
251
- a_string_matching(/foo/)
252
- ).to be_aliased_to(
253
- match(/foo/)
254
- ).with_description('a string matching /foo/')
255
- end
256
-
257
- specify do
258
- expect(
259
- an_object_matching(/foo/)
260
- ).to be_aliased_to(
261
- match(/foo/)
262
- ).with_description('an object matching /foo/')
263
- end
264
-
265
- specify do
266
- expect(
267
- match_regex(/foo/)
268
- ).to be_aliased_to(
269
- match(/foo/)
270
- ).with_description('match regex /foo/')
271
- end
272
-
273
- specify do
274
- expect(
275
- matching(/foo/)
276
- ).to be_aliased_to(
277
- match(/foo/)
278
- ).with_description('matching /foo/')
279
- end
280
-
281
- specify do
282
- expect(
283
- a_block_outputting('foo').to_stdout
284
- ).to be_aliased_to(
285
- output('foo').to_stdout
286
- ).with_description('a block outputting "foo" to stdout')
287
- end
288
-
289
- specify do
290
- expect(
291
- a_block_outputting('foo').to_stderr
292
- ).to be_aliased_to(
293
- output('foo').to_stderr
294
- ).with_description('a block outputting "foo" to stderr')
295
- end
296
-
297
- specify do
298
- expect(
299
- a_block_raising(ArgumentError)
300
- ).to be_aliased_to(
301
- raise_error(ArgumentError)
302
- ).with_description('a block raising ArgumentError')
303
- end
304
-
305
- specify do
306
- expect(
307
- raising(ArgumentError)
308
- ).to be_aliased_to(
309
- raise_error(ArgumentError)
310
- ).with_description("raising ArgumentError")
311
- end
312
-
313
- specify do
314
- expect(
315
- an_object_responding_to(:foo)
316
- ).to be_aliased_to(
317
- respond_to(:foo)
318
- ).with_description("an object responding to #foo")
319
- end
320
-
321
- specify do
322
- expect(
323
- responding_to(:foo)
324
- ).to be_aliased_to(
325
- respond_to(:foo)
326
- ).with_description("responding to #foo")
327
- end
328
-
329
- specify do
330
- expect(
331
- an_object_satisfying { }
332
- ).to be_aliased_to(
333
- satisfy { }
334
- ).with_description("an object satisfying block")
335
- end
336
-
337
- specify do
338
- expect(
339
- satisfying { }
340
- ).to be_aliased_to(
341
- satisfy { }
342
- ).with_description("satisfying block")
343
- end
344
-
345
- specify do
346
- expect(
347
- a_collection_starting_with(23)
348
- ).to be_aliased_to(
349
- start_with(23)
350
- ).with_description("a collection starting with 23")
351
- end
352
-
353
- specify do
354
- expect(
355
- a_string_starting_with("z")
356
- ).to be_aliased_to(
357
- start_with("z")
358
- ).with_description('a string starting with "z"')
359
- end
360
-
361
- specify do
362
- expect(
363
- starting_with("d")
364
- ).to be_aliased_to(
365
- start_with("d")
366
- ).with_description('starting with "d"')
367
- end
368
-
369
- specify do
370
- expect(
371
- a_block_throwing(:foo)
372
- ).to be_aliased_to(
373
- throw_symbol(:foo)
374
- ).with_description("a block throwing :foo")
375
- end
376
-
377
- specify do
378
- expect(
379
- throwing(:foo)
380
- ).to be_aliased_to(
381
- throw_symbol(:foo)
382
- ).with_description("throwing :foo")
383
- end
384
-
385
- specify do
386
- expect(
387
- a_block_yielding_control
388
- ).to be_aliased_to(
389
- yield_control
390
- ).with_description("a block yielding control")
391
- end
392
-
393
- specify do
394
- expect(
395
- yielding_control
396
- ).to be_aliased_to(
397
- yield_control
398
- ).with_description("yielding control")
399
- end
400
-
401
- specify do
402
- expect(
403
- a_block_yielding_with_no_args
404
- ).to be_aliased_to(
405
- yield_with_no_args
406
- ).with_description("a block yielding with no args")
407
- end
408
-
409
- specify do
410
- expect(
411
- yielding_with_no_args
412
- ).to be_aliased_to(
413
- yield_with_no_args
414
- ).with_description("yielding with no args")
415
- end
416
-
417
- specify do
418
- expect(
419
- a_block_yielding_with_args
420
- ).to be_aliased_to(
421
- yield_with_args
422
- ).with_description("a block yielding with args")
423
- end
424
-
425
- specify do
426
- expect(
427
- yielding_with_args
428
- ).to be_aliased_to(
429
- yield_with_args
430
- ).with_description("yielding with args")
431
- end
432
-
433
- specify do
434
- expect(
435
- a_block_yielding_successive_args
436
- ).to be_aliased_to(
437
- yield_successive_args
438
- ).with_description("a block yielding successive args()")
439
- end
440
-
441
- specify do
442
- expect(
443
- yielding_successive_args
444
- ).to be_aliased_to(
445
- yield_successive_args
446
- ).with_description("yielding successive args()")
447
- end
448
- end
449
- end