rspec-expectations 3.13.6 → 4.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +27 -9
- data/LICENSE.md +1 -0
- data/README.md +7 -67
- data/lib/rspec/expectations/block_snippet_extractor.rb +3 -1
- data/lib/rspec/expectations/configuration.rb +2 -99
- data/lib/rspec/expectations/expectation_target.rb +11 -12
- data/lib/rspec/expectations/fail_with.rb +2 -0
- data/lib/rspec/expectations/failure_aggregator.rb +4 -2
- data/lib/rspec/expectations/handler.rb +2 -103
- data/lib/rspec/expectations/minitest_integration.rb +2 -0
- data/lib/rspec/expectations/version.rb +3 -1
- data/lib/rspec/expectations.rb +5 -0
- data/lib/rspec/matchers/aliased_matcher.rb +2 -0
- data/lib/rspec/matchers/built_in/all.rb +2 -0
- data/lib/rspec/matchers/built_in/base_matcher.rb +10 -30
- data/lib/rspec/matchers/built_in/be.rb +4 -2
- data/lib/rspec/matchers/built_in/be_between.rb +2 -0
- data/lib/rspec/matchers/built_in/be_instance_of.rb +2 -0
- data/lib/rspec/matchers/built_in/be_kind_of.rb +2 -0
- data/lib/rspec/matchers/built_in/be_within.rb +2 -0
- data/lib/rspec/matchers/built_in/change.rb +24 -39
- data/lib/rspec/matchers/built_in/compound.rb +16 -12
- data/lib/rspec/matchers/built_in/contain_exactly.rb +6 -15
- data/lib/rspec/matchers/built_in/count_expectation.rb +7 -17
- data/lib/rspec/matchers/built_in/cover.rb +2 -0
- data/lib/rspec/matchers/built_in/eq.rb +2 -0
- data/lib/rspec/matchers/built_in/eql.rb +2 -0
- data/lib/rspec/matchers/built_in/equal.rb +2 -0
- data/lib/rspec/matchers/built_in/exist.rb +4 -2
- data/lib/rspec/matchers/built_in/has.rb +9 -40
- data/lib/rspec/matchers/built_in/have_attributes.rb +2 -0
- data/lib/rspec/matchers/built_in/include.rb +8 -14
- data/lib/rspec/matchers/built_in/match.rb +3 -39
- data/lib/rspec/matchers/built_in/output.rb +50 -14
- data/lib/rspec/matchers/built_in/raise_error.rb +15 -25
- data/lib/rspec/matchers/built_in/respond_to.rb +3 -1
- data/lib/rspec/matchers/built_in/satisfy.rb +2 -0
- data/lib/rspec/matchers/built_in/start_or_end_with.rb +2 -6
- data/lib/rspec/matchers/built_in/throw_symbol.rb +4 -7
- data/lib/rspec/matchers/built_in/yield.rb +21 -50
- data/lib/rspec/matchers/built_in.rb +2 -3
- data/lib/rspec/matchers/composable.rb +2 -1
- data/lib/rspec/matchers/dsl.rb +19 -71
- data/lib/rspec/matchers/english_phrasing.rb +2 -18
- data/lib/rspec/matchers/fail_matchers.rb +2 -0
- data/lib/rspec/matchers/generated_descriptions.rb +2 -0
- data/lib/rspec/matchers/matcher_delegator.rb +9 -13
- data/lib/rspec/matchers/matcher_protocol.rb +2 -0
- data/lib/rspec/matchers/multi_matcher_diff.rb +5 -3
- data/lib/rspec/matchers.rb +11 -60
- data.tar.gz.sig +0 -0
- metadata +14 -16
- metadata.gz.sig +0 -0
- data/lib/rspec/expectations/syntax.rb +0 -132
- data/lib/rspec/matchers/built_in/operators.rb +0 -128
data/lib/rspec/matchers/dsl.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
RSpec::Support.require_rspec_support "with_keywords_when_needed"
|
|
2
4
|
|
|
3
5
|
module RSpec
|
|
@@ -80,21 +82,13 @@ module RSpec
|
|
|
80
82
|
|
|
81
83
|
private
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"use the `block_arg` method to access the block")
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
else
|
|
93
|
-
# :nocov:
|
|
94
|
-
def warn_about_block_args(*)
|
|
95
|
-
# There's no way to detect block params on 1.8 since the method reflection APIs don't expose it
|
|
85
|
+
def warn_about_block_args(name, declarations)
|
|
86
|
+
declarations.parameters.each do |type, arg_name|
|
|
87
|
+
next unless type == :block
|
|
88
|
+
RSpec.warning("Your `#{name}` custom matcher receives a block argument (`#{arg_name}`), " \
|
|
89
|
+
"but due to limitations in ruby, RSpec cannot provide the block. Instead, " \
|
|
90
|
+
"use the `block_arg` method to access the block")
|
|
96
91
|
end
|
|
97
|
-
# :nocov:
|
|
98
92
|
end
|
|
99
93
|
|
|
100
94
|
RSpec.configure { |c| c.extend self } if RSpec.respond_to?(:configure)
|
|
@@ -271,10 +265,8 @@ module RSpec
|
|
|
271
265
|
# Convenience for defining methods on this matcher to create a fluent
|
|
272
266
|
# interface. The trick about fluent interfaces is that each method must
|
|
273
267
|
# return self in order to chain methods together. `chain` handles that
|
|
274
|
-
# for you. If the method is invoked and
|
|
275
|
-
#
|
|
276
|
-
# hash been enabled, the chained method name and args will be added to the
|
|
277
|
-
# default description and failure message.
|
|
268
|
+
# for you. If the method is invoked, the chained method name and args
|
|
269
|
+
# will be added to the default description and failure message.
|
|
278
270
|
#
|
|
279
271
|
# In the common case where you just want the chained method to store some
|
|
280
272
|
# value(s) for later use (e.g. in `match`), you can provide one or more
|
|
@@ -309,6 +301,8 @@ module RSpec
|
|
|
309
301
|
end
|
|
310
302
|
end
|
|
311
303
|
|
|
304
|
+
private
|
|
305
|
+
|
|
312
306
|
def assign_attributes(attr_names)
|
|
313
307
|
attr_reader(*attr_names)
|
|
314
308
|
private(*attr_names)
|
|
@@ -320,12 +314,6 @@ module RSpec
|
|
|
320
314
|
end
|
|
321
315
|
end
|
|
322
316
|
|
|
323
|
-
# assign_attributes isn't defined in the private section below because
|
|
324
|
-
# that makes MRI 1.9.2 emit a warning about private attributes.
|
|
325
|
-
private :assign_attributes
|
|
326
|
-
|
|
327
|
-
private
|
|
328
|
-
|
|
329
317
|
# Does the following:
|
|
330
318
|
#
|
|
331
319
|
# - Defines the named method using a user-provided block
|
|
@@ -348,34 +336,6 @@ module RSpec
|
|
|
348
336
|
our_def ||= lambda { super(*actual_arg_for(user_def)) }
|
|
349
337
|
define_method(method_name, &our_def)
|
|
350
338
|
end
|
|
351
|
-
|
|
352
|
-
# Defines deprecated macro methods from RSpec 2 for backwards compatibility.
|
|
353
|
-
# @deprecated Use the methods from {Macros} instead.
|
|
354
|
-
module Deprecated
|
|
355
|
-
# @deprecated Use {Macros#match} instead.
|
|
356
|
-
def match_for_should(&definition)
|
|
357
|
-
RSpec.deprecate("`match_for_should`", :replacement => "`match`")
|
|
358
|
-
match(&definition)
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
# @deprecated Use {Macros#match_when_negated} instead.
|
|
362
|
-
def match_for_should_not(&definition)
|
|
363
|
-
RSpec.deprecate("`match_for_should_not`", :replacement => "`match_when_negated`")
|
|
364
|
-
match_when_negated(&definition)
|
|
365
|
-
end
|
|
366
|
-
|
|
367
|
-
# @deprecated Use {Macros#failure_message} instead.
|
|
368
|
-
def failure_message_for_should(&definition)
|
|
369
|
-
RSpec.deprecate("`failure_message_for_should`", :replacement => "`failure_message`")
|
|
370
|
-
failure_message(&definition)
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
# @deprecated Use {Macros#failure_message_when_negated} instead.
|
|
374
|
-
def failure_message_for_should_not(&definition)
|
|
375
|
-
RSpec.deprecate("`failure_message_for_should_not`", :replacement => "`failure_message_when_negated`")
|
|
376
|
-
failure_message_when_negated(&definition)
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
339
|
end
|
|
380
340
|
|
|
381
341
|
# Defines default implementations of the matcher
|
|
@@ -386,7 +346,7 @@ module RSpec
|
|
|
386
346
|
include BuiltIn::BaseMatcher::DefaultFailureMessages
|
|
387
347
|
|
|
388
348
|
# @api private
|
|
389
|
-
# Used internally by
|
|
349
|
+
# Used internally by handlers and compound matchers.
|
|
390
350
|
def diffable?
|
|
391
351
|
false
|
|
392
352
|
end
|
|
@@ -416,8 +376,6 @@ module RSpec
|
|
|
416
376
|
private
|
|
417
377
|
|
|
418
378
|
def chained_method_clause_sentences
|
|
419
|
-
return '' unless Expectations.configuration.include_chain_clauses_in_custom_matcher_descriptions?
|
|
420
|
-
|
|
421
379
|
@chained_method_clauses.map do |(method_name, method_args)|
|
|
422
380
|
english_name = EnglishPhrasing.split_words(method_name)
|
|
423
381
|
arg_list = EnglishPhrasing.list(method_args)
|
|
@@ -442,7 +400,6 @@ module RSpec
|
|
|
442
400
|
|
|
443
401
|
# Makes the macro methods available to an `RSpec::Matchers.define` block.
|
|
444
402
|
extend Macros
|
|
445
|
-
extend Macros::Deprecated
|
|
446
403
|
|
|
447
404
|
# Exposes the value being matched against -- generally the object
|
|
448
405
|
# object wrapped by `expect`.
|
|
@@ -471,6 +428,7 @@ module RSpec
|
|
|
471
428
|
class << self
|
|
472
429
|
# See `Macros#define_user_override` above, for an explanation.
|
|
473
430
|
include(@user_method_defs = Module.new)
|
|
431
|
+
|
|
474
432
|
self
|
|
475
433
|
end
|
|
476
434
|
RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *expected, &declarations)
|
|
@@ -501,21 +459,11 @@ module RSpec
|
|
|
501
459
|
"#<#{self.class.name} #{name}>"
|
|
502
460
|
end
|
|
503
461
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
super || @matcher_execution_context.respond_to?(method, include_private)
|
|
510
|
-
end
|
|
511
|
-
else # for 1.8.7
|
|
512
|
-
# :nocov:
|
|
513
|
-
# Indicates that this matcher responds to messages
|
|
514
|
-
# from the `@matcher_execution_context` as well.
|
|
515
|
-
def respond_to?(method, include_private=false)
|
|
516
|
-
super || @matcher_execution_context.respond_to?(method, include_private)
|
|
517
|
-
end
|
|
518
|
-
# :nocov:
|
|
462
|
+
# Indicates that this matcher responds to messages
|
|
463
|
+
# from the `@matcher_execution_context` as well.
|
|
464
|
+
# Also, supports getting a method object for such methods.
|
|
465
|
+
def respond_to_missing?(method, include_private=false)
|
|
466
|
+
super || @matcher_execution_context.respond_to?(method, include_private)
|
|
519
467
|
end
|
|
520
468
|
|
|
521
469
|
private
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RSpec
|
|
2
4
|
module Matchers
|
|
3
5
|
# Facilitates converting ruby objects to English phrases.
|
|
@@ -37,24 +39,6 @@ module RSpec
|
|
|
37
39
|
" #{items[0...-1].join(', ')}, and #{items[-1]}"
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
|
-
|
|
41
|
-
if RUBY_VERSION == '1.8.7'
|
|
42
|
-
# Not sure why, but on travis on 1.8.7 we have gotten these warnings:
|
|
43
|
-
# lib/rspec/matchers/english_phrasing.rb:28: warning: default `to_a' will be obsolete
|
|
44
|
-
# So it appears that `Array` can trigger that (e.g. by calling `to_a` on the passed object?)
|
|
45
|
-
# So here we replace `Kernel#Array` with our own warning-free implementation for 1.8.7.
|
|
46
|
-
# @private
|
|
47
|
-
# rubocop:disable Naming/MethodName
|
|
48
|
-
# :nocov:
|
|
49
|
-
def self.Array(obj)
|
|
50
|
-
case obj
|
|
51
|
-
when Array then obj
|
|
52
|
-
else [obj]
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
# :nocov:
|
|
56
|
-
# rubocop:enable Naming/MethodName
|
|
57
|
-
end
|
|
58
42
|
end
|
|
59
43
|
end
|
|
60
44
|
end
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RSpec
|
|
2
4
|
module Matchers
|
|
3
5
|
# Provides a base class with as little methods as possible, so that
|
|
4
6
|
# most methods can be delegated via `method_missing`.
|
|
5
7
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
8
|
+
# BasicObject could be used for this purpose, but it introduces
|
|
9
|
+
# some extra complexity with constant resolution, so the BlankSlate
|
|
10
|
+
# pattern was prefered.
|
|
11
|
+
#
|
|
9
12
|
# @private
|
|
10
13
|
class BaseDelegator
|
|
11
14
|
kept_methods = [
|
|
@@ -30,6 +33,7 @@ module RSpec
|
|
|
30
33
|
# @private
|
|
31
34
|
class MatcherDelegator < BaseDelegator
|
|
32
35
|
include Composable
|
|
36
|
+
|
|
33
37
|
attr_reader :base_matcher
|
|
34
38
|
|
|
35
39
|
def initialize(base_matcher)
|
|
@@ -40,16 +44,8 @@ module RSpec
|
|
|
40
44
|
base_matcher.__send__(*args, &block)
|
|
41
45
|
end
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
super || base_matcher.respond_to?(name, include_all)
|
|
46
|
-
end
|
|
47
|
-
else
|
|
48
|
-
# :nocov:
|
|
49
|
-
def respond_to?(name, include_all=false)
|
|
50
|
-
super || base_matcher.respond_to?(name, include_all)
|
|
51
|
-
end
|
|
52
|
-
# :nocov:
|
|
47
|
+
def respond_to_missing?(name, include_all=false)
|
|
48
|
+
super || base_matcher.respond_to?(name, include_all)
|
|
53
49
|
end
|
|
54
50
|
|
|
55
51
|
def initialize_copy(other)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RSpec
|
|
2
4
|
module Matchers
|
|
3
5
|
# @api private
|
|
@@ -7,7 +9,7 @@ module RSpec
|
|
|
7
9
|
# @private
|
|
8
10
|
# Default diff label when there is only one matcher in diff
|
|
9
11
|
# output
|
|
10
|
-
DEFAULT_DIFF_LABEL = "Diff:"
|
|
12
|
+
DEFAULT_DIFF_LABEL = "Diff:"
|
|
11
13
|
|
|
12
14
|
# @private
|
|
13
15
|
# Maximum readable matcher description length
|
|
@@ -70,8 +72,8 @@ module RSpec
|
|
|
70
72
|
diff = differ.diff(actual, expected)
|
|
71
73
|
next if diff.strip.empty?
|
|
72
74
|
if diff == "\e[0m\n\e[0m"
|
|
73
|
-
"#{diff_label}\n" \
|
|
74
|
-
"
|
|
75
|
+
"#{diff_label}\n " \
|
|
76
|
+
"<The diff is empty, are your objects producing identical `#inspect` output?>"
|
|
75
77
|
else
|
|
76
78
|
"#{diff_label}#{diff}"
|
|
77
79
|
end
|
data/lib/rspec/matchers.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rspec/support'
|
|
2
4
|
RSpec::Support.require_rspec_support 'matcher_definition'
|
|
3
5
|
RSpec::Support.define_optimized_require_for_rspec(:matchers) { |f| require_relative(f) }
|
|
@@ -238,7 +240,7 @@ module RSpec
|
|
|
238
240
|
# best to find a more positive name for the negated form, such as
|
|
239
241
|
# `avoid_changing` rather than `not_change`.
|
|
240
242
|
#
|
|
241
|
-
module Matchers
|
|
243
|
+
module Matchers
|
|
242
244
|
extend ::RSpec::Matchers::DSL
|
|
243
245
|
|
|
244
246
|
# @!macro [attach] alias_matcher
|
|
@@ -260,7 +262,6 @@ module RSpec
|
|
|
260
262
|
# @!method self.define_negated_matcher(negated_name, base_name, &description_override)
|
|
261
263
|
# Extended from {RSpec::Matchers::DSL#define_negated_matcher}.
|
|
262
264
|
|
|
263
|
-
# @method expect
|
|
264
265
|
# Supports `expect(actual).to matcher` syntax by wrapping `actual` in an
|
|
265
266
|
# `ExpectationTarget`.
|
|
266
267
|
# @example
|
|
@@ -269,6 +270,9 @@ module RSpec
|
|
|
269
270
|
# @return [Expectations::ExpectationTarget]
|
|
270
271
|
# @see Expectations::ExpectationTarget#to
|
|
271
272
|
# @see Expectations::ExpectationTarget#not_to
|
|
273
|
+
def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block)
|
|
274
|
+
::RSpec::Expectations::ExpectationTarget.for(value, block)
|
|
275
|
+
end
|
|
272
276
|
|
|
273
277
|
# Allows multiple expectations in the provided block to fail, and then
|
|
274
278
|
# aggregates them into a single exception, rather than aborting on the
|
|
@@ -499,9 +503,6 @@ module RSpec
|
|
|
499
503
|
# This works for collections. Pass in multiple args and it will only
|
|
500
504
|
# pass if all args are found in collection.
|
|
501
505
|
#
|
|
502
|
-
# @note This is also available using the `=~` operator with `should`,
|
|
503
|
-
# but `=~` is not supported with `expect`.
|
|
504
|
-
#
|
|
505
506
|
# @example
|
|
506
507
|
# expect([1, 2, 3]).to contain_exactly(1, 2, 3)
|
|
507
508
|
# expect([1, 2, 3]).to contain_exactly(1, 3, 2)
|
|
@@ -524,7 +525,6 @@ module RSpec
|
|
|
524
525
|
# expect(1..10).not_to cover(11)
|
|
525
526
|
# expect(1..10).not_to cover(5) # fails
|
|
526
527
|
#
|
|
527
|
-
# ### Warning:: Ruby >= 1.9 only
|
|
528
528
|
def cover(*values)
|
|
529
529
|
BuiltIn::Cover.new(*values)
|
|
530
530
|
end
|
|
@@ -689,15 +689,9 @@ module RSpec
|
|
|
689
689
|
# :c => { :d => (a_value < 3) }
|
|
690
690
|
# }
|
|
691
691
|
# )
|
|
692
|
-
#
|
|
693
|
-
# @note The `match_regex` alias is deprecated and is not recommended for use.
|
|
694
|
-
# It was added in 2.12.1 to facilitate its use from within custom
|
|
695
|
-
# matchers (due to how the custom matcher DSL was evaluated in 2.x,
|
|
696
|
-
# `match` could not be used there), but is no longer needed in 3.x.
|
|
697
692
|
def match(expected)
|
|
698
693
|
BuiltIn::Match.new(expected)
|
|
699
694
|
end
|
|
700
|
-
alias_matcher :match_regex, :match
|
|
701
695
|
alias_matcher :an_object_matching, :match
|
|
702
696
|
alias_matcher :a_string_matching, :match
|
|
703
697
|
alias_matcher :matching, :match
|
|
@@ -970,21 +964,12 @@ module RSpec
|
|
|
970
964
|
end
|
|
971
965
|
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
|
972
966
|
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
method =~ DYNAMIC_MATCHER_REGEX || super
|
|
976
|
-
end
|
|
977
|
-
else # for 1.8.7
|
|
978
|
-
# :nocov:
|
|
979
|
-
def respond_to?(method, *)
|
|
980
|
-
method = method.to_s
|
|
981
|
-
method =~ DYNAMIC_MATCHER_REGEX || super
|
|
982
|
-
end
|
|
983
|
-
public :respond_to?
|
|
984
|
-
# :nocov:
|
|
967
|
+
def respond_to_missing?(method, *)
|
|
968
|
+
method =~ DYNAMIC_MATCHER_REGEX || super
|
|
985
969
|
end
|
|
986
970
|
|
|
987
971
|
# @api private
|
|
972
|
+
# rubocop:disable Lint/IneffectiveAccessModifier
|
|
988
973
|
def self.is_a_matcher?(obj)
|
|
989
974
|
return true if ::RSpec::Matchers::BuiltIn::BaseMatcher === obj
|
|
990
975
|
begin
|
|
@@ -996,8 +981,7 @@ module RSpec
|
|
|
996
981
|
end
|
|
997
982
|
return false unless obj.respond_to?(:matches?)
|
|
998
983
|
|
|
999
|
-
obj.respond_to?(:failure_message)
|
|
1000
|
-
obj.respond_to?(:failure_message_for_should) # support legacy matchers
|
|
984
|
+
obj.respond_to?(:failure_message)
|
|
1001
985
|
end
|
|
1002
986
|
|
|
1003
987
|
::RSpec::Support.register_matcher_definition do |obj|
|
|
@@ -1008,39 +992,6 @@ module RSpec
|
|
|
1008
992
|
def self.is_a_describable_matcher?(obj)
|
|
1009
993
|
is_a_matcher?(obj) && obj.respond_to?(:description)
|
|
1010
994
|
end
|
|
1011
|
-
|
|
1012
|
-
class << self
|
|
1013
|
-
private
|
|
1014
|
-
|
|
1015
|
-
if RSpec::Support::Ruby.mri? && RUBY_VERSION[0, 3] == '1.9'
|
|
1016
|
-
# Note that `included` doesn't work for this because it is triggered
|
|
1017
|
-
# _after_ `RSpec::Matchers` is an ancestor of the inclusion host, rather
|
|
1018
|
-
# than _before_, like `append_features`. It's important we check this before
|
|
1019
|
-
# in order to find the cases where it was already previously included.
|
|
1020
|
-
# @api private
|
|
1021
|
-
# :nocov:
|
|
1022
|
-
def append_features(mod)
|
|
1023
|
-
return super if mod < self # `mod < self` indicates a re-inclusion.
|
|
1024
|
-
|
|
1025
|
-
subclasses = ObjectSpace.each_object(Class).select { |c| c < mod && c < self }
|
|
1026
|
-
return super unless subclasses.any?
|
|
1027
|
-
|
|
1028
|
-
subclasses.reject! { |s| subclasses.any? { |s2| s < s2 } } # Filter to the root ancestor.
|
|
1029
|
-
subclasses = subclasses.map { |s| "`#{s}`" }.join(", ")
|
|
1030
|
-
|
|
1031
|
-
RSpec.warning "`#{self}` has been included in a superclass (`#{mod}`) " \
|
|
1032
|
-
"after previously being included in subclasses (#{subclasses}), " \
|
|
1033
|
-
"which can trigger infinite recursion from `super` due to an MRI 1.9 bug " \
|
|
1034
|
-
"(https://redmine.ruby-lang.org/issues/3351). To work around this, " \
|
|
1035
|
-
"either upgrade to MRI 2.0+, include a dup of the module (e.g. " \
|
|
1036
|
-
"`include #{self}.dup`), or find a way to include `#{self}` in `#{mod}` " \
|
|
1037
|
-
"before it is included in subclasses (#{subclasses}). See " \
|
|
1038
|
-
"https://github.com/rspec/rspec-expectations/issues/814 for more info"
|
|
1039
|
-
|
|
1040
|
-
super
|
|
1041
|
-
end
|
|
1042
|
-
# :nocov:
|
|
1043
|
-
end
|
|
1044
|
-
end
|
|
995
|
+
# rubocop:enable Lint/IneffectiveAccessModifier
|
|
1045
996
|
end
|
|
1046
997
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec-expectations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0.beta1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Baker
|
|
@@ -49,36 +49,36 @@ dependencies:
|
|
|
49
49
|
name: rspec-support
|
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - '='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 4.0.0.beta1
|
|
55
55
|
type: :runtime
|
|
56
56
|
prerelease: false
|
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - '='
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 4.0.0.beta1
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
|
63
63
|
name: diff-lcs
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 1.
|
|
68
|
+
version: 1.6.0
|
|
69
69
|
- - "<"
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
|
-
version: '
|
|
71
|
+
version: '3.0'
|
|
72
72
|
type: :runtime
|
|
73
73
|
prerelease: false
|
|
74
74
|
version_requirements: !ruby/object:Gem::Requirement
|
|
75
75
|
requirements:
|
|
76
76
|
- - ">="
|
|
77
77
|
- !ruby/object:Gem::Version
|
|
78
|
-
version: 1.
|
|
78
|
+
version: 1.6.0
|
|
79
79
|
- - "<"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
81
|
+
version: '3.0'
|
|
82
82
|
description: rspec-expectations provides a simple, readable API to express expected
|
|
83
83
|
outcomes of a code example.
|
|
84
84
|
email: rspec@googlegroups.com
|
|
@@ -99,7 +99,6 @@ files:
|
|
|
99
99
|
- lib/rspec/expectations/failure_aggregator.rb
|
|
100
100
|
- lib/rspec/expectations/handler.rb
|
|
101
101
|
- lib/rspec/expectations/minitest_integration.rb
|
|
102
|
-
- lib/rspec/expectations/syntax.rb
|
|
103
102
|
- lib/rspec/expectations/version.rb
|
|
104
103
|
- lib/rspec/matchers.rb
|
|
105
104
|
- lib/rspec/matchers/aliased_matcher.rb
|
|
@@ -124,7 +123,6 @@ files:
|
|
|
124
123
|
- lib/rspec/matchers/built_in/have_attributes.rb
|
|
125
124
|
- lib/rspec/matchers/built_in/include.rb
|
|
126
125
|
- lib/rspec/matchers/built_in/match.rb
|
|
127
|
-
- lib/rspec/matchers/built_in/operators.rb
|
|
128
126
|
- lib/rspec/matchers/built_in/output.rb
|
|
129
127
|
- lib/rspec/matchers/built_in/raise_error.rb
|
|
130
128
|
- lib/rspec/matchers/built_in/respond_to.rb
|
|
@@ -145,11 +143,11 @@ licenses:
|
|
|
145
143
|
- MIT
|
|
146
144
|
metadata:
|
|
147
145
|
bug_tracker_uri: https://github.com/rspec/rspec/issues
|
|
148
|
-
changelog_uri: https://github.com/rspec/rspec/
|
|
146
|
+
changelog_uri: https://github.com/rspec/rspec/tree/rspec-expectations-v4.0.0.beta1/rspec-expectations/Changelog.md
|
|
149
147
|
documentation_uri: https://rspec.info/documentation/
|
|
150
148
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
|
149
|
+
source_code_uri: https://github.com/rspec/rspec/tree/rspec-expectations-v4.0.0.beta1/rspec-expectations
|
|
151
150
|
rubygems_mfa_required: 'true'
|
|
152
|
-
source_code_uri: https://github.com/rspec/rspec/blob/rspec-expectations-v3.13.6/rspec-expectations
|
|
153
151
|
rdoc_options:
|
|
154
152
|
- "--charset=UTF-8"
|
|
155
153
|
require_paths:
|
|
@@ -158,14 +156,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
158
156
|
requirements:
|
|
159
157
|
- - ">="
|
|
160
158
|
- !ruby/object:Gem::Version
|
|
161
|
-
version:
|
|
159
|
+
version: 3.0.0
|
|
162
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
161
|
requirements:
|
|
164
162
|
- - ">="
|
|
165
163
|
- !ruby/object:Gem::Version
|
|
166
164
|
version: '0'
|
|
167
165
|
requirements: []
|
|
168
|
-
rubygems_version: 4.0.
|
|
166
|
+
rubygems_version: 4.0.3
|
|
169
167
|
specification_version: 4
|
|
170
|
-
summary: rspec-expectations-
|
|
168
|
+
summary: rspec-expectations-4.0.0.beta1
|
|
171
169
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
module RSpec
|
|
2
|
-
module Expectations
|
|
3
|
-
# @api private
|
|
4
|
-
# Provides methods for enabling and disabling the available
|
|
5
|
-
# syntaxes provided by rspec-expectations.
|
|
6
|
-
module Syntax
|
|
7
|
-
module_function
|
|
8
|
-
|
|
9
|
-
# @api private
|
|
10
|
-
# Determines where we add `should` and `should_not`.
|
|
11
|
-
def default_should_host
|
|
12
|
-
@default_should_host ||= ::Object.ancestors.last
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# @api private
|
|
16
|
-
# Instructs rspec-expectations to warn on first usage of `should` or `should_not`.
|
|
17
|
-
# Enabled by default. This is largely here to facilitate testing.
|
|
18
|
-
def warn_about_should!
|
|
19
|
-
@warn_about_should = true
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# @api private
|
|
23
|
-
# Generates a deprecation warning for the given method if no warning
|
|
24
|
-
# has already been issued.
|
|
25
|
-
def warn_about_should_unless_configured(method_name)
|
|
26
|
-
return unless @warn_about_should
|
|
27
|
-
|
|
28
|
-
RSpec.deprecate(
|
|
29
|
-
"Using `#{method_name}` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax",
|
|
30
|
-
:replacement => "the new `:expect` syntax or explicitly enable `:should` with `config.expect_with(:rspec) { |c| c.syntax = :should }`"
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
@warn_about_should = false
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @api private
|
|
37
|
-
# Enables the `should` syntax.
|
|
38
|
-
def enable_should(syntax_host=default_should_host)
|
|
39
|
-
@warn_about_should = false if syntax_host == default_should_host
|
|
40
|
-
return if should_enabled?(syntax_host)
|
|
41
|
-
|
|
42
|
-
syntax_host.module_exec do
|
|
43
|
-
def should(matcher=nil, message=nil, &block)
|
|
44
|
-
::RSpec::Expectations::Syntax.warn_about_should_unless_configured(::Kernel.__method__)
|
|
45
|
-
::RSpec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def should_not(matcher=nil, message=nil, &block)
|
|
49
|
-
::RSpec::Expectations::Syntax.warn_about_should_unless_configured(::Kernel.__method__)
|
|
50
|
-
::RSpec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# @api private
|
|
56
|
-
# Disables the `should` syntax.
|
|
57
|
-
def disable_should(syntax_host=default_should_host)
|
|
58
|
-
return unless should_enabled?(syntax_host)
|
|
59
|
-
|
|
60
|
-
syntax_host.module_exec do
|
|
61
|
-
undef should
|
|
62
|
-
undef should_not
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# @api private
|
|
67
|
-
# Enables the `expect` syntax.
|
|
68
|
-
def enable_expect(syntax_host=::RSpec::Matchers)
|
|
69
|
-
return if expect_enabled?(syntax_host)
|
|
70
|
-
|
|
71
|
-
syntax_host.module_exec do
|
|
72
|
-
def expect(value=::RSpec::Expectations::ExpectationTarget::UndefinedValue, &block)
|
|
73
|
-
::RSpec::Expectations::ExpectationTarget.for(value, block)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
# @api private
|
|
79
|
-
# Disables the `expect` syntax.
|
|
80
|
-
def disable_expect(syntax_host=::RSpec::Matchers)
|
|
81
|
-
return unless expect_enabled?(syntax_host)
|
|
82
|
-
|
|
83
|
-
syntax_host.module_exec do
|
|
84
|
-
undef expect
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# @api private
|
|
89
|
-
# Indicates whether or not the `should` syntax is enabled.
|
|
90
|
-
def should_enabled?(syntax_host=default_should_host)
|
|
91
|
-
syntax_host.method_defined?(:should)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# @api private
|
|
95
|
-
# Indicates whether or not the `expect` syntax is enabled.
|
|
96
|
-
def expect_enabled?(syntax_host=::RSpec::Matchers)
|
|
97
|
-
syntax_host.method_defined?(:expect)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
if defined?(BasicObject)
|
|
104
|
-
# The legacy `:should` syntax adds the following methods directly to
|
|
105
|
-
# `BasicObject` so that they are available off of any object. Note, however,
|
|
106
|
-
# that this syntax does not always play nice with delegate/proxy objects.
|
|
107
|
-
# We recommend you use the non-monkeypatching `:expect` syntax instead.
|
|
108
|
-
class BasicObject
|
|
109
|
-
# @method should(matcher, message)
|
|
110
|
-
# Passes if `matcher` returns true. Available on every `Object`.
|
|
111
|
-
# @example
|
|
112
|
-
# actual.should eq expected
|
|
113
|
-
# actual.should match /expression/
|
|
114
|
-
# @param [Matcher]
|
|
115
|
-
# matcher
|
|
116
|
-
# @param [String] message optional message to display when the expectation fails
|
|
117
|
-
# @return [Boolean] true if the expectation succeeds (else raises)
|
|
118
|
-
# @note This is only available when you have enabled the `:should` syntax.
|
|
119
|
-
# @see RSpec::Matchers
|
|
120
|
-
|
|
121
|
-
# @method should_not(matcher, message)
|
|
122
|
-
# Passes if `matcher` returns false. Available on every `Object`.
|
|
123
|
-
# @example
|
|
124
|
-
# actual.should_not eq expected
|
|
125
|
-
# @param [Matcher]
|
|
126
|
-
# matcher
|
|
127
|
-
# @param [String] message optional message to display when the expectation fails
|
|
128
|
-
# @return [Boolean] false if the negative expectation succeeds (else raises)
|
|
129
|
-
# @note This is only available when you have enabled the `:should` syntax.
|
|
130
|
-
# @see RSpec::Matchers
|
|
131
|
-
end
|
|
132
|
-
end
|