mocha 2.7.1 → 2.8.0

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/RELEASE.md +15 -0
  3. data/lib/mocha/api.rb +1 -1
  4. data/lib/mocha/configuration.rb +1 -1
  5. data/lib/mocha/expectation.rb +2 -2
  6. data/lib/mocha/parameter_matchers/all_of.rb +30 -21
  7. data/lib/mocha/parameter_matchers/any_of.rb +36 -27
  8. data/lib/mocha/parameter_matchers/any_parameters.rb +28 -19
  9. data/lib/mocha/parameter_matchers/anything.rb +25 -16
  10. data/lib/mocha/parameter_matchers/base.rb +22 -4
  11. data/lib/mocha/parameter_matchers/deprecations.rb +46 -0
  12. data/lib/mocha/parameter_matchers/equals.rb +31 -22
  13. data/lib/mocha/parameter_matchers/equivalent_uri.rb +30 -21
  14. data/lib/mocha/parameter_matchers/has_entries.rb +31 -22
  15. data/lib/mocha/parameter_matchers/has_entry.rb +72 -65
  16. data/lib/mocha/parameter_matchers/has_key.rb +31 -22
  17. data/lib/mocha/parameter_matchers/has_keys.rb +31 -22
  18. data/lib/mocha/parameter_matchers/has_value.rb +31 -22
  19. data/lib/mocha/parameter_matchers/includes.rb +69 -60
  20. data/lib/mocha/parameter_matchers/instance_methods.rb +1 -1
  21. data/lib/mocha/parameter_matchers/instance_of.rb +31 -22
  22. data/lib/mocha/parameter_matchers/is_a.rb +32 -23
  23. data/lib/mocha/parameter_matchers/kind_of.rb +31 -22
  24. data/lib/mocha/parameter_matchers/not.rb +31 -22
  25. data/lib/mocha/parameter_matchers/optionally.rb +43 -33
  26. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +6 -1
  27. data/lib/mocha/parameter_matchers/regexp_matches.rb +31 -22
  28. data/lib/mocha/parameter_matchers/responds_with.rb +55 -46
  29. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +30 -21
  30. data/lib/mocha/parameter_matchers.rb +6 -2
  31. data/lib/mocha/version.rb +1 -1
  32. metadata +4 -3
@@ -1,33 +1,40 @@
1
1
  require 'mocha/parameter_matchers/base'
2
+ require 'mocha/parameter_matchers/deprecations'
2
3
 
3
4
  module Mocha
4
5
  module ParameterMatchers
5
- # Matches any object that is a +klass+.
6
- #
7
- # @param [Class] klass expected class.
8
- # @return [IsA] parameter matcher.
9
- #
10
- # @see Expectation#with
11
- # @see Kernel#is_a?
12
- #
13
- # @example Actual parameter is a +Integer+.
14
- # object = mock()
15
- # object.expects(:method_1).with(is_a(Integer))
16
- # object.method_1(99)
17
- # # no error raised
18
- #
19
- # @example Actual parameter is not a +Integer+.
20
- # object = mock()
21
- # object.expects(:method_1).with(is_a(Integer))
22
- # object.method_1('string')
23
- # # error raised, because method_1 was not called with an Integer
24
- #
25
- def is_a(klass) # rubocop:disable Naming/PredicateName
26
- IsA.new(klass)
6
+ module Methods
7
+ # Matches any object that is a +klass+.
8
+ #
9
+ # @param [Class] klass expected class.
10
+ # @return [IsA] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ # @see Kernel#is_a?
14
+ #
15
+ # @example Actual parameter is a +Integer+.
16
+ # object = mock()
17
+ # object.expects(:method_1).with(is_a(Integer))
18
+ # object.method_1(99)
19
+ # # no error raised
20
+ #
21
+ # @example Actual parameter is not a +Integer+.
22
+ # object = mock()
23
+ # object.expects(:method_1).with(is_a(Integer))
24
+ # object.method_1('string')
25
+ # # error raised, because method_1 was not called with an Integer
26
+ #
27
+ def is_a(klass) # rubocop:disable Naming/PredicateName
28
+ IsA.new(klass)
29
+ end
27
30
  end
28
31
 
32
+ define_deprecated_matcher_method(:is_a)
33
+
29
34
  # Parameter matcher which matches when actual parameter is a specific class.
30
- class IsA < Base
35
+ class IsA
36
+ include BaseMethods
37
+
31
38
  # @private
32
39
  def initialize(klass)
33
40
  @klass = klass
@@ -44,5 +51,7 @@ module Mocha
44
51
  "is_a(#{@klass.mocha_inspect})"
45
52
  end
46
53
  end
54
+
55
+ provide_deprecated_access_to(:IsA)
47
56
  end
48
57
  end
@@ -1,32 +1,39 @@
1
1
  require 'mocha/parameter_matchers/base'
2
+ require 'mocha/parameter_matchers/deprecations'
2
3
 
3
4
  module Mocha
4
5
  module ParameterMatchers
5
- # Matches any +Object+ that is a kind of +klass+.
6
- #
7
- # @param [Class] klass expected class.
8
- # @return [KindOf] parameter matcher.
9
- #
10
- # @see Expectation#with
11
- # @see Kernel#kind_of?
12
- #
13
- # @example Actual parameter is a kind of +Integer+.
14
- # object = mock()
15
- # object.expects(:method_1).with(kind_of(Integer))
16
- # object.method_1(99)
17
- # # no error raised
18
- #
19
- # @example Actual parameter is not a kind of +Integer+.
20
- # object = mock()
21
- # object.expects(:method_1).with(kind_of(Integer))
22
- # object.method_1('string')
23
- # # error raised, because method_1 was not called with a kind of Integer
24
- def kind_of(klass)
25
- KindOf.new(klass)
6
+ module Methods
7
+ # Matches any +Object+ that is a kind of +klass+.
8
+ #
9
+ # @param [Class] klass expected class.
10
+ # @return [KindOf] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ # @see Kernel#kind_of?
14
+ #
15
+ # @example Actual parameter is a kind of +Integer+.
16
+ # object = mock()
17
+ # object.expects(:method_1).with(kind_of(Integer))
18
+ # object.method_1(99)
19
+ # # no error raised
20
+ #
21
+ # @example Actual parameter is not a kind of +Integer+.
22
+ # object = mock()
23
+ # object.expects(:method_1).with(kind_of(Integer))
24
+ # object.method_1('string')
25
+ # # error raised, because method_1 was not called with a kind of Integer
26
+ def kind_of(klass)
27
+ KindOf.new(klass)
28
+ end
26
29
  end
27
30
 
31
+ define_deprecated_matcher_method(:kind_of)
32
+
28
33
  # Parameter matcher which matches when actual parameter is a kind of specified class.
29
- class KindOf < Base
34
+ class KindOf
35
+ include BaseMethods
36
+
30
37
  # @private
31
38
  def initialize(klass)
32
39
  @klass = klass
@@ -45,5 +52,7 @@ module Mocha
45
52
  "kind_of(#{@klass.mocha_inspect})"
46
53
  end
47
54
  end
55
+
56
+ provide_deprecated_access_to(:KindOf)
48
57
  end
49
58
  end
@@ -1,32 +1,39 @@
1
1
  require 'mocha/parameter_matchers/base'
2
+ require 'mocha/parameter_matchers/deprecations'
2
3
 
3
4
  module Mocha
4
5
  module ParameterMatchers
5
- # Matches if +matcher+ does *not* match.
6
- #
7
- # @param [Base] matcher matcher whose logic to invert.
8
- # @return [Not] parameter matcher.
9
- #
10
- # @see Expectation#with
11
- #
12
- # @example Actual parameter does not include the value +1+.
13
- # object = mock()
14
- # object.expects(:method_1).with(Not(includes(1)))
15
- # object.method_1([0, 2, 3])
16
- # # no error raised
17
- #
18
- # @example Actual parameter does include the value +1+.
19
- # object = mock()
20
- # object.expects(:method_1).with(Not(includes(1)))
21
- # object.method_1([0, 1, 2, 3])
22
- # # error raised, because method_1 was not called with object not including 1
23
- #
24
- def Not(matcher) # rubocop:disable Naming/MethodName
25
- Not.new(matcher)
6
+ module Methods
7
+ # Matches if +matcher+ does *not* match.
8
+ #
9
+ # @param [BaseMethods] matcher matcher whose logic to invert.
10
+ # @return [Not] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ #
14
+ # @example Actual parameter does not include the value +1+.
15
+ # object = mock()
16
+ # object.expects(:method_1).with(Not(includes(1)))
17
+ # object.method_1([0, 2, 3])
18
+ # # no error raised
19
+ #
20
+ # @example Actual parameter does include the value +1+.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(Not(includes(1)))
23
+ # object.method_1([0, 1, 2, 3])
24
+ # # error raised, because method_1 was not called with object not including 1
25
+ #
26
+ def Not(matcher) # rubocop:disable Naming/MethodName
27
+ Not.new(matcher)
28
+ end
26
29
  end
27
30
 
31
+ define_deprecated_matcher_method(:Not)
32
+
28
33
  # Parameter matcher which inverts the logic of the specified matcher using a logical NOT operation.
29
- class Not < Base
34
+ class Not
35
+ include BaseMethods
36
+
30
37
  # @private
31
38
  def initialize(matcher)
32
39
  @matcher = matcher
@@ -43,5 +50,7 @@ module Mocha
43
50
  "Not(#{@matcher.mocha_inspect})"
44
51
  end
45
52
  end
53
+
54
+ provide_deprecated_access_to(:Not)
46
55
  end
47
56
  end
@@ -1,41 +1,49 @@
1
+ require 'mocha/parameter_matchers/deprecations'
2
+
1
3
  module Mocha
2
4
  module ParameterMatchers
3
- # Matches optional parameters if available.
4
- #
5
- # @param [*Array<Base>] matchers matchers for optional parameters.
6
- # @return [Optionally] parameter matcher.
7
- #
8
- # @see Expectation#with
9
- #
10
- # @example Only the two required parameters are supplied and they both match their expected value.
11
- # object = mock()
12
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
13
- # object.method_1(1, 2)
14
- # # no error raised
15
- #
16
- # @example Both required parameters and one of the optional parameters are supplied and they all match their expected value.
17
- # object = mock()
18
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
19
- # object.method_1(1, 2, 3)
20
- # # no error raised
21
- #
22
- # @example Both required parameters and both of the optional parameters are supplied and they all match their expected value.
23
- # object = mock()
24
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
25
- # object.method_1(1, 2, 3, 4)
26
- # # no error raised
27
- #
28
- # @example One of the actual optional parameters does not match the expected value.
29
- # object = mock()
30
- # object.expects(:method_1).with(1, 2, optionally(3, 4))
31
- # object.method_1(1, 2, 3, 5)
32
- # # error raised, because optional parameters did not match
33
- def optionally(*matchers)
34
- Optionally.new(*matchers)
5
+ module Methods
6
+ # Matches optional parameters if available.
7
+ #
8
+ # @param [*Array<BaseMethods>] matchers matchers for optional parameters.
9
+ # @return [Optionally] parameter matcher.
10
+ #
11
+ # @see Expectation#with
12
+ #
13
+ # @example Only the two required parameters are supplied and they both match their expected value.
14
+ # object = mock()
15
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
16
+ # object.method_1(1, 2)
17
+ # # no error raised
18
+ #
19
+ # @example Both required parameters and one of the optional parameters are supplied and they all match their expected value.
20
+ # object = mock()
21
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
22
+ # object.method_1(1, 2, 3)
23
+ # # no error raised
24
+ #
25
+ # @example Both required parameters and both of the optional parameters are supplied and they all match their expected value.
26
+ # object = mock()
27
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
28
+ # object.method_1(1, 2, 3, 4)
29
+ # # no error raised
30
+ #
31
+ # @example One of the actual optional parameters does not match the expected value.
32
+ # object = mock()
33
+ # object.expects(:method_1).with(1, 2, optionally(3, 4))
34
+ # object.method_1(1, 2, 3, 5)
35
+ # # error raised, because optional parameters did not match
36
+ def optionally(*matchers)
37
+ Optionally.new(*matchers)
38
+ end
35
39
  end
36
40
 
41
+ define_deprecated_matcher_method(:optionally)
42
+
37
43
  # Parameter matcher which allows optional parameters to be specified.
38
- class Optionally < Base
44
+ class Optionally
45
+ include BaseMethods
46
+
39
47
  # @private
40
48
  def initialize(*parameters)
41
49
  @matchers = parameters.map(&:to_matcher)
@@ -57,5 +65,7 @@ module Mocha
57
65
  "optionally(#{@matchers.map(&:mocha_inspect).join(', ')})"
58
66
  end
59
67
  end
68
+
69
+ provide_deprecated_access_to(:Optionally)
60
70
  end
61
71
  end
@@ -2,11 +2,14 @@ require 'mocha/configuration'
2
2
  require 'mocha/deprecation'
3
3
  require 'mocha/parameter_matchers/base'
4
4
  require 'mocha/parameter_matchers/has_entries'
5
+ require 'mocha/parameter_matchers/deprecations'
5
6
 
6
7
  module Mocha
7
8
  module ParameterMatchers
8
9
  # @private
9
- class PositionalOrKeywordHash < Base
10
+ class PositionalOrKeywordHash
11
+ include BaseMethods
12
+
10
13
  def initialize(value, expectation)
11
14
  @value = value
12
15
  @expectation = expectation
@@ -62,5 +65,7 @@ module Mocha
62
65
  "defined at #{@expectation.definition_location}"
63
66
  end
64
67
  end
68
+
69
+ provide_deprecated_access_to(:PositionalOrKeywordHash)
65
70
  end
66
71
  end
@@ -1,32 +1,39 @@
1
1
  require 'mocha/parameter_matchers/base'
2
+ require 'mocha/parameter_matchers/deprecations'
2
3
 
3
4
  module Mocha
4
5
  module ParameterMatchers
5
- # Matches any object that matches +regexp+.
6
- #
7
- # @param [Regexp] regexp regular expression to match.
8
- # @return [RegexpMatches] parameter matcher.
9
- #
10
- # @see Expectation#with
11
- #
12
- # @example Actual parameter is matched by specified regular expression.
13
- # object = mock()
14
- # object.expects(:method_1).with(regexp_matches(/e/))
15
- # object.method_1('hello')
16
- # # no error raised
17
- #
18
- # @example Actual parameter is not matched by specified regular expression.
19
- # object = mock()
20
- # object.expects(:method_1).with(regexp_matches(/a/))
21
- # object.method_1('hello')
22
- # # error raised, because method_1 was not called with a parameter that matched the
23
- # # regular expression
24
- def regexp_matches(regexp)
25
- RegexpMatches.new(regexp)
6
+ module Methods
7
+ # Matches any object that matches +regexp+.
8
+ #
9
+ # @param [Regexp] regexp regular expression to match.
10
+ # @return [RegexpMatches] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ #
14
+ # @example Actual parameter is matched by specified regular expression.
15
+ # object = mock()
16
+ # object.expects(:method_1).with(regexp_matches(/e/))
17
+ # object.method_1('hello')
18
+ # # no error raised
19
+ #
20
+ # @example Actual parameter is not matched by specified regular expression.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(regexp_matches(/a/))
23
+ # object.method_1('hello')
24
+ # # error raised, because method_1 was not called with a parameter that matched the
25
+ # # regular expression
26
+ def regexp_matches(regexp)
27
+ RegexpMatches.new(regexp)
28
+ end
26
29
  end
27
30
 
31
+ define_deprecated_matcher_method(:regexp_matches)
32
+
28
33
  # Parameter matcher which matches if specified regular expression matches actual paramter.
29
- class RegexpMatches < Base
34
+ class RegexpMatches
35
+ include BaseMethods
36
+
30
37
  # @private
31
38
  def initialize(regexp)
32
39
  @regexp = regexp
@@ -44,5 +51,7 @@ module Mocha
44
51
  "regexp_matches(#{@regexp.mocha_inspect})"
45
52
  end
46
53
  end
54
+
55
+ provide_deprecated_access_to(:RegexpMatches)
47
56
  end
48
57
  end
@@ -1,60 +1,67 @@
1
1
  require 'mocha/parameter_matchers/base'
2
2
  require 'mocha/parameter_matchers/all_of'
3
+ require 'mocha/parameter_matchers/deprecations'
3
4
  require 'yaml'
4
5
 
5
6
  module Mocha
6
7
  module ParameterMatchers
7
- # @overload def responds_with(message, result)
8
- # Matches any object that responds to +message+ with +result+. To put it another way, it tests the quack, not the duck.
9
- # @param [Symbol] message method to invoke.
10
- # @param [Object] result expected result of sending +message+.
11
- # @overload def responds_with(messages_vs_results)
12
- # Matches any object that responds to all the messages with the corresponding results as specified by +messages_vs_results+.
13
- # @param [Hash<Symbol,Object>] messages_vs_results +Hash+ of messages vs results.
14
- # @raise [ArgumentError] if +messages_vs_results+ does not contain at least one entry.
15
- #
16
- # @return [RespondsWith] parameter matcher.
17
- #
18
- # @see Expectation#with
19
- #
20
- # @example Actual parameter responds with "FOO" when :upcase is invoked.
21
- # object = mock()
22
- # object.expects(:method_1).with(responds_with(:upcase, "FOO"))
23
- # object.method_1("foo")
24
- # # no error raised, because "foo".upcase == "FOO"
25
- #
26
- # @example Actual parameter does not respond with "FOO" when :upcase is invoked.
27
- # object = mock()
28
- # object.expects(:method_1).with(responds_with(:upcase, "BAR"))
29
- # object.method_1("foo")
30
- # # error raised, because "foo".upcase != "BAR"
31
- #
32
- # @example Actual parameter responds with "FOO" when :upcase is invoked and "oof" when :reverse is invoked.
33
- # object = mock()
34
- # object.expects(:method_1).with(responds_with(upcase: "FOO", reverse: "oof"))
35
- # object.method_1("foo")
36
- # # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof"
37
- def responds_with(*options)
38
- case options.length
39
- when 0
40
- raise ArgumentError, 'No arguments. Expecting at least one.'
41
- when 1
42
- option = options.first
43
- raise ArgumentError, 'Argument is not a Hash.' unless option.is_a?(Hash)
44
- raise ArgumentError, 'Argument has no entries.' if option.empty?
8
+ module Methods
9
+ # @overload def responds_with(message, result)
10
+ # Matches any object that responds to +message+ with +result+. To put it another way, it tests the quack, not the duck.
11
+ # @param [Symbol] message method to invoke.
12
+ # @param [Object] result expected result of sending +message+.
13
+ # @overload def responds_with(messages_vs_results)
14
+ # Matches any object that responds to all the messages with the corresponding results as specified by +messages_vs_results+.
15
+ # @param [Hash<Symbol,Object>] messages_vs_results +Hash+ of messages vs results.
16
+ # @raise [ArgumentError] if +messages_vs_results+ does not contain at least one entry.
17
+ #
18
+ # @return [RespondsWith] parameter matcher.
19
+ #
20
+ # @see Expectation#with
21
+ #
22
+ # @example Actual parameter responds with "FOO" when :upcase is invoked.
23
+ # object = mock()
24
+ # object.expects(:method_1).with(responds_with(:upcase, "FOO"))
25
+ # object.method_1("foo")
26
+ # # no error raised, because "foo".upcase == "FOO"
27
+ #
28
+ # @example Actual parameter does not respond with "FOO" when :upcase is invoked.
29
+ # object = mock()
30
+ # object.expects(:method_1).with(responds_with(:upcase, "BAR"))
31
+ # object.method_1("foo")
32
+ # # error raised, because "foo".upcase != "BAR"
33
+ #
34
+ # @example Actual parameter responds with "FOO" when :upcase is invoked and "oof" when :reverse is invoked.
35
+ # object = mock()
36
+ # object.expects(:method_1).with(responds_with(upcase: "FOO", reverse: "oof"))
37
+ # object.method_1("foo")
38
+ # # no error raised, because "foo".upcase == "FOO" and "foo".reverse == "oof"
39
+ def responds_with(*options)
40
+ case options.length
41
+ when 0
42
+ raise ArgumentError, 'No arguments. Expecting at least one.'
43
+ when 1
44
+ option = options.first
45
+ raise ArgumentError, 'Argument is not a Hash.' unless option.is_a?(Hash)
46
+ raise ArgumentError, 'Argument has no entries.' if option.empty?
45
47
 
46
- matchers = option.map { |message, result| RespondsWith.new(message, result) }
47
- AllOf.new(*matchers)
48
- when 2
49
- message, result = options
50
- RespondsWith.new(message, result)
51
- else
52
- raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a message and a result).'
48
+ matchers = option.map { |message, result| RespondsWith.new(message, result) }
49
+ AllOf.new(*matchers)
50
+ when 2
51
+ message, result = options
52
+ RespondsWith.new(message, result)
53
+ else
54
+ raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a message and a result).'
55
+ end
53
56
  end
54
57
  end
55
58
 
59
+ define_deprecated_matcher_method(:responds_with)
60
+
56
61
  # Parameter matcher which matches if actual parameter returns expected result when specified method is invoked.
57
- class RespondsWith < Base
62
+ class RespondsWith
63
+ include BaseMethods
64
+
58
65
  # @private
59
66
  def initialize(message, result)
60
67
  @message = message
@@ -72,5 +79,7 @@ module Mocha
72
79
  "responds_with(#{@message.mocha_inspect}, #{@result.mocha_inspect})"
73
80
  end
74
81
  end
82
+
83
+ provide_deprecated_access_to(:RespondsWith)
75
84
  end
76
85
  end
@@ -1,32 +1,39 @@
1
1
  require 'mocha/parameter_matchers/base'
2
+ require 'mocha/parameter_matchers/deprecations'
2
3
  require 'yaml'
3
4
 
4
5
  module Mocha
5
6
  module ParameterMatchers
6
- # Matches any YAML that represents the specified +object+
7
- #
8
- # @param [Object] object object whose YAML to compare.
9
- # @return [YamlEquivalent] parameter matcher.
10
- #
11
- # @see Expectation#with
12
- #
13
- # @example Actual parameter is YAML equivalent of specified +object+.
14
- # object = mock()
15
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
16
- # object.method_1("--- \n- 1\n- 2\n- 3\n")
17
- # # no error raised
18
- #
19
- # @example Actual parameter is not YAML equivalent of specified +object+.
20
- # object = mock()
21
- # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
22
- # object.method_1("--- \n- 1\n- 2\n")
23
- # # error raised, because method_1 was not called with YAML representing the specified Array
24
- def yaml_equivalent(object)
25
- YamlEquivalent.new(object)
7
+ module Methods
8
+ # Matches any YAML that represents the specified +object+
9
+ #
10
+ # @param [Object] object object whose YAML to compare.
11
+ # @return [YamlEquivalent] parameter matcher.
12
+ #
13
+ # @see Expectation#with
14
+ #
15
+ # @example Actual parameter is YAML equivalent of specified +object+.
16
+ # object = mock()
17
+ # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
18
+ # object.method_1("--- \n- 1\n- 2\n- 3\n")
19
+ # # no error raised
20
+ #
21
+ # @example Actual parameter is not YAML equivalent of specified +object+.
22
+ # object = mock()
23
+ # object.expects(:method_1).with(yaml_equivalent(1, 2, 3))
24
+ # object.method_1("--- \n- 1\n- 2\n")
25
+ # # error raised, because method_1 was not called with YAML representing the specified Array
26
+ def yaml_equivalent(object)
27
+ YamlEquivalent.new(object)
28
+ end
26
29
  end
27
30
 
31
+ define_deprecated_matcher_method(:yaml_equivalent)
32
+
28
33
  # Parameter matcher which matches if actual parameter is YAML equivalent of specified object.
29
- class YamlEquivalent < Base
34
+ class YamlEquivalent
35
+ include BaseMethods
36
+
30
37
  # @private
31
38
  def initialize(object)
32
39
  @object = object
@@ -45,5 +52,7 @@ module Mocha
45
52
  "yaml_equivalent(#{@object.mocha_inspect})"
46
53
  end
47
54
  end
55
+
56
+ provide_deprecated_access_to(:YamlEquivalent)
48
57
  end
49
58
  end
@@ -1,8 +1,12 @@
1
1
  module Mocha
2
- # Used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested.
3
- module ParameterMatchers; end
2
+ # Matcher classes used as parameters for {Expectation#with} to restrict the parameter values which will match the expectation. Can be nested. Build matcher instances in tests using methods in {Methods}, e.g. {Methods#includes}.
3
+ module ParameterMatchers
4
+ # These methods build instances of the {ParameterMatchers} classes which are used with {Expectation#with} to restrict the parameter values. Can be nested, e.g. see {Methods#all_of} examples.
5
+ module Methods; end
6
+ end
4
7
  end
5
8
 
9
+ require 'mocha/parameter_matchers/deprecations'
6
10
  require 'mocha/parameter_matchers/instance_methods'
7
11
 
8
12
  require 'mocha/parameter_matchers/all_of'
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '2.7.1'.freeze
2
+ VERSION = '2.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-09 00:00:00.000000000 Z
11
+ date: 2025-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords
@@ -94,6 +94,7 @@ files:
94
94
  - lib/mocha/parameter_matchers/any_parameters.rb
95
95
  - lib/mocha/parameter_matchers/anything.rb
96
96
  - lib/mocha/parameter_matchers/base.rb
97
+ - lib/mocha/parameter_matchers/deprecations.rb
97
98
  - lib/mocha/parameter_matchers/equals.rb
98
99
  - lib/mocha/parameter_matchers/equivalent_uri.rb
99
100
  - lib/mocha/parameter_matchers/has_entries.rb
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  requirements: []
157
- rubygems_version: 3.5.22
158
+ rubygems_version: 3.5.3
158
159
  signing_key:
159
160
  specification_version: 4
160
161
  summary: Mocking and stubbing library