mocha 2.8.0 → 3.0.0.pre.rc.1

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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +67 -3
  3. data/.rubocop_todo.yml +25 -13
  4. data/Gemfile +11 -27
  5. data/README.md +3 -4
  6. data/RELEASE.md +30 -8
  7. data/Rakefile +6 -5
  8. data/gemfiles/Gemfile.minitest.latest +3 -3
  9. data/gemfiles/Gemfile.rubocop +9 -0
  10. data/gemfiles/Gemfile.test-unit.latest +3 -3
  11. data/lib/mocha/any_instance_method.rb +2 -0
  12. data/lib/mocha/any_instance_receiver.rb +20 -0
  13. data/lib/mocha/api.rb +5 -3
  14. data/lib/mocha/argument_iterator.rb +5 -5
  15. data/lib/mocha/backtrace_filter.rb +2 -0
  16. data/lib/mocha/{block_matcher.rb → block_matchers.rb} +2 -0
  17. data/lib/mocha/cardinality.rb +2 -2
  18. data/lib/mocha/central.rb +4 -0
  19. data/lib/mocha/change_state_side_effect.rb +2 -0
  20. data/lib/mocha/class_methods.rb +5 -4
  21. data/lib/mocha/configuration.rb +19 -42
  22. data/lib/mocha/default_name.rb +15 -0
  23. data/lib/mocha/default_receiver.rb +13 -0
  24. data/lib/mocha/deprecation.rb +15 -9
  25. data/lib/mocha/detection/minitest.rb +2 -0
  26. data/lib/mocha/detection/test_unit.rb +4 -1
  27. data/lib/mocha/error_with_filtered_backtrace.rb +2 -0
  28. data/lib/mocha/exception_raiser.rb +3 -0
  29. data/lib/mocha/expectation.rb +59 -25
  30. data/lib/mocha/expectation_error.rb +2 -0
  31. data/lib/mocha/expectation_error_factory.rb +2 -0
  32. data/lib/mocha/expectation_list.rb +2 -0
  33. data/lib/mocha/hooks.rb +2 -0
  34. data/lib/mocha/impersonating_any_instance_name.rb +13 -0
  35. data/lib/mocha/impersonating_name.rb +13 -0
  36. data/lib/mocha/in_state_ordering_constraint.rb +2 -0
  37. data/lib/mocha/inspect.rb +13 -10
  38. data/lib/mocha/instance_method.rb +2 -0
  39. data/lib/mocha/integration/assertion_counter.rb +2 -0
  40. data/lib/mocha/integration/minitest/adapter.rb +3 -0
  41. data/lib/mocha/integration/minitest.rb +4 -3
  42. data/lib/mocha/integration/monkey_patcher.rb +4 -2
  43. data/lib/mocha/integration/test_unit/adapter.rb +3 -0
  44. data/lib/mocha/integration/test_unit.rb +4 -3
  45. data/lib/mocha/invocation.rb +9 -6
  46. data/lib/mocha/logger.rb +2 -0
  47. data/lib/mocha/macos_version.rb +2 -0
  48. data/lib/mocha/method_matcher.rb +2 -0
  49. data/lib/mocha/minitest.rb +2 -1
  50. data/lib/mocha/mock.rb +8 -8
  51. data/lib/mocha/mockery.rb +16 -6
  52. data/lib/mocha/name.rb +13 -0
  53. data/lib/mocha/not_initialized_error.rb +2 -0
  54. data/lib/mocha/object_methods.rb +7 -5
  55. data/lib/mocha/object_receiver.rb +20 -0
  56. data/lib/mocha/parameter_matchers/all_of.rb +23 -28
  57. data/lib/mocha/parameter_matchers/any_of.rb +29 -34
  58. data/lib/mocha/parameter_matchers/any_parameters.rb +21 -26
  59. data/lib/mocha/parameter_matchers/anything.rb +18 -23
  60. data/lib/mocha/parameter_matchers/base.rb +5 -21
  61. data/lib/mocha/parameter_matchers/equals.rb +24 -29
  62. data/lib/mocha/parameter_matchers/equivalent_uri.rb +23 -28
  63. data/lib/mocha/parameter_matchers/has_entries.rb +24 -29
  64. data/lib/mocha/parameter_matchers/has_entry.rb +68 -70
  65. data/lib/mocha/parameter_matchers/has_key.rb +25 -29
  66. data/lib/mocha/parameter_matchers/has_keys.rb +25 -30
  67. data/lib/mocha/parameter_matchers/has_value.rb +25 -29
  68. data/lib/mocha/parameter_matchers/includes.rb +65 -73
  69. data/lib/mocha/parameter_matchers/instance_methods.rb +5 -3
  70. data/lib/mocha/parameter_matchers/instance_of.rb +24 -29
  71. data/lib/mocha/parameter_matchers/is_a.rb +25 -30
  72. data/lib/mocha/parameter_matchers/kind_of.rb +24 -29
  73. data/lib/mocha/parameter_matchers/not.rb +24 -29
  74. data/lib/mocha/parameter_matchers/optionally.rb +35 -40
  75. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +39 -19
  76. data/lib/mocha/parameter_matchers/regexp_matches.rb +25 -29
  77. data/lib/mocha/parameter_matchers/responds_with.rb +48 -53
  78. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +23 -28
  79. data/lib/mocha/parameter_matchers.rb +4 -6
  80. data/lib/mocha/parameters_matcher.rb +9 -1
  81. data/lib/mocha/raised_exception.rb +2 -0
  82. data/lib/mocha/return_values.rb +2 -0
  83. data/lib/mocha/ruby_version.rb +3 -0
  84. data/lib/mocha/sequence.rb +2 -0
  85. data/lib/mocha/single_return_value.rb +1 -1
  86. data/lib/mocha/state_machine.rb +2 -0
  87. data/lib/mocha/stubbed_method.rb +9 -2
  88. data/lib/mocha/stubbing_error.rb +2 -0
  89. data/lib/mocha/test_unit.rb +2 -1
  90. data/lib/mocha/thrower.rb +2 -0
  91. data/lib/mocha/thrown_object.rb +2 -0
  92. data/lib/mocha/version.rb +3 -1
  93. data/lib/mocha/yield_parameters.rb +2 -0
  94. data/lib/mocha.rb +5 -0
  95. data/mocha.gemspec +10 -4
  96. metadata +17 -16
  97. data/lib/mocha/debug.rb +0 -9
  98. data/lib/mocha/integration/minitest/exception_translation.rb +0 -14
  99. data/lib/mocha/is_a.rb +0 -7
  100. data/lib/mocha/names.rb +0 -43
  101. data/lib/mocha/parameter_matchers/deprecations.rb +0 -46
  102. data/lib/mocha/receivers.rb +0 -45
@@ -1,40 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/parameter_matchers/base'
2
4
  require 'mocha/parameter_matchers/all_of'
3
5
  require 'mocha/parameter_matchers/has_entry'
4
- require 'mocha/parameter_matchers/deprecations'
5
6
 
6
7
  module Mocha
7
8
  module ParameterMatchers
8
- module Methods
9
- # Matches +Hash+ containing all +entries+.
10
- #
11
- # @param [Hash] entries expected +Hash+ entries.
12
- # @return [HasEntries] parameter matcher.
13
- #
14
- # @see Expectation#with
15
- #
16
- # @example Actual parameter contains all expected entries.
17
- # object = mock()
18
- # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
19
- # object.method_1('key_1' => 1, 'key_2' => 2, 'key_3' => 3)
20
- # # no error raised
21
- #
22
- # @example Actual parameter does not contain all expected entries.
23
- # object = mock()
24
- # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
25
- # object.method_1('key_1' => 1, 'key_2' => 99)
26
- # # error raised, because method_1 was not called with Hash containing entries: 'key_1' => 1, 'key_2' => 2
27
- #
28
- def has_entries(entries) # rubocop:disable Naming/PredicateName
29
- HasEntries.new(entries)
30
- end
9
+ # Matches +Hash+ containing all +entries+.
10
+ #
11
+ # @param [Hash] entries expected +Hash+ entries.
12
+ # @return [HasEntries] parameter matcher.
13
+ #
14
+ # @see Expectation#with
15
+ #
16
+ # @example Actual parameter contains all expected entries.
17
+ # object = mock()
18
+ # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
19
+ # object.method_1('key_1' => 1, 'key_2' => 2, 'key_3' => 3)
20
+ # # no error raised
21
+ #
22
+ # @example Actual parameter does not contain all expected entries.
23
+ # object = mock()
24
+ # object.expects(:method_1).with(has_entries('key_1' => 1, 'key_2' => 2))
25
+ # object.method_1('key_1' => 1, 'key_2' => 99)
26
+ # # error raised, because method_1 was not called with Hash containing entries: 'key_1' => 1, 'key_2' => 2
27
+ #
28
+ def has_entries(entries) # rubocop:disable Naming/PredicateName
29
+ HasEntries.new(entries)
31
30
  end
32
31
 
33
- define_deprecated_matcher_method(:has_entries)
34
-
35
32
  # Parameter matcher which matches when actual parameter contains all expected +Hash+ entries.
36
33
  class HasEntries
37
- include BaseMethods
34
+ include Base
38
35
 
39
36
  # @private
40
37
  def initialize(entries, exact: false)
@@ -58,7 +55,5 @@ module Mocha
58
55
  @exact ? @entries.mocha_inspect : "has_entries(#{@entries.mocha_inspect})"
59
56
  end
60
57
  end
61
-
62
- provide_deprecated_access_to(:HasEntries)
63
58
  end
64
59
  end
@@ -1,67 +1,64 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/parameter_matchers/base'
2
- require 'mocha/parameter_matchers/deprecations'
3
4
 
4
5
  module Mocha
5
6
  module ParameterMatchers
6
- module Methods
7
- # Matches +Hash+ containing entry with +key+ and +value+.
8
- #
9
- # @overload def has_entry(key, value)
10
- # @param [Object] key key for entry.
11
- # @param [Object] value value for entry.
12
- # @overload def has_entry(single_entry_hash)
13
- # @param [Hash] single_entry_hash +Hash+ with single entry.
14
- # @raise [ArgumentError] if +single_entry_hash+ does not contain exactly one entry.
15
- #
16
- # @return [HasEntry] parameter matcher.
17
- #
18
- # @see Expectation#with
19
- #
20
- # @example Actual parameter contains expected entry supplied as key and value.
21
- # object = mock()
22
- # object.expects(:method_1).with(has_entry('key_1', 1))
23
- # object.method_1('key_1' => 1, 'key_2' => 2)
24
- # # no error raised
25
- #
26
- # @example Actual parameter contains expected entry supplied as +Hash+ entry.
27
- # object = mock()
28
- # object.expects(:method_1).with(has_entry('key_1' => 1))
29
- # object.method_1('key_1' => 1, 'key_2' => 2)
30
- # # no error raised
31
- #
32
- # @example Actual parameter does not contain expected entry supplied as key and value.
33
- # object = mock()
34
- # object.expects(:method_1).with(has_entry('key_1', 1))
35
- # object.method_1('key_1' => 2, 'key_2' => 1)
36
- # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
37
- #
38
- # @example Actual parameter does not contain expected entry supplied as +Hash+ entry.
39
- #
40
- # object = mock()
41
- # object.expects(:method_1).with(has_entry('key_1' => 1))
42
- # object.method_1('key_1' => 2, 'key_2' => 1)
43
- # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
44
- #
45
- def has_entry(*options) # rubocop:disable Naming/PredicateName
46
- case options.length
47
- when 0
48
- raise ArgumentError, 'No arguments. Expecting at least one.'
49
- when 1
50
- key, value = HasEntry.parse_option(options[0])
51
- when 2
52
- key, value = options
53
- else
54
- raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a key and a value).'
55
- end
56
- HasEntry.new(key, value)
7
+ # Matches +Hash+ containing entry with +key+ and +value+.
8
+ #
9
+ # @overload def has_entry(key, value)
10
+ # @param [Object] key key for entry.
11
+ # @param [Object] value value for entry.
12
+ # @overload def has_entry(single_entry_hash)
13
+ # @param [Hash] single_entry_hash +Hash+ with single entry.
14
+ # @raise [ArgumentError] if +single_entry_hash+ does not contain exactly one entry.
15
+ #
16
+ # @return [HasEntry] parameter matcher.
17
+ #
18
+ # @see Expectation#with
19
+ #
20
+ # @example Actual parameter contains expected entry supplied as key and value.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(has_entry('key_1', 1))
23
+ # object.method_1('key_1' => 1, 'key_2' => 2)
24
+ # # no error raised
25
+ #
26
+ # @example Actual parameter contains expected entry supplied as +Hash+ entry.
27
+ # object = mock()
28
+ # object.expects(:method_1).with(has_entry('key_1' => 1))
29
+ # object.method_1('key_1' => 1, 'key_2' => 2)
30
+ # # no error raised
31
+ #
32
+ # @example Actual parameter does not contain expected entry supplied as key and value.
33
+ # object = mock()
34
+ # object.expects(:method_1).with(has_entry('key_1', 1))
35
+ # object.method_1('key_1' => 2, 'key_2' => 1)
36
+ # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
37
+ #
38
+ # @example Actual parameter does not contain expected entry supplied as +Hash+ entry.
39
+ #
40
+ # object = mock()
41
+ # object.expects(:method_1).with(has_entry('key_1' => 1))
42
+ # object.method_1('key_1' => 2, 'key_2' => 1)
43
+ # # error raised, because method_1 was not called with Hash containing entry: 'key_1' => 1
44
+ #
45
+ def has_entry(*options) # rubocop:disable Naming/PredicateName
46
+ case options.length
47
+ when 0
48
+ raise ArgumentError, 'No arguments. Expecting at least one.'
49
+ when 1
50
+ key, value = parse_option(options[0])
51
+ when 2
52
+ key, value = options
53
+ else
54
+ raise ArgumentError, 'Too many arguments; use either a single argument (must be a Hash) or two arguments (a key and a value).'
57
55
  end
56
+ HasEntry.new(key, value)
58
57
  end
59
58
 
60
- define_deprecated_matcher_method(:has_entry)
61
-
62
59
  # Parameter matcher which matches when actual parameter contains expected +Hash+ entry.
63
60
  class HasEntry
64
- include BaseMethods
61
+ include Base
65
62
 
66
63
  # @private
67
64
  def initialize(key, value)
@@ -73,6 +70,7 @@ module Mocha
73
70
  def matches?(available_parameters)
74
71
  parameter = available_parameters.shift
75
72
  return false unless parameter.respond_to?(:keys) && parameter.respond_to?(:[])
73
+
76
74
  matching_keys = parameter.keys.select { |key| @key.to_matcher.matches?([key]) }
77
75
  matching_keys.any? { |key| @value.to_matcher.matches?([parameter[key]]) }
78
76
  end
@@ -81,25 +79,25 @@ module Mocha
81
79
  def mocha_inspect
82
80
  "has_entry(#{@key.mocha_inspect} => #{@value.mocha_inspect})"
83
81
  end
82
+ end
84
83
 
85
- # @private
86
- def self.parse_option(option)
87
- case option
88
- when Hash
89
- case option.length
90
- when 0
91
- raise ArgumentError, 'Argument has no entries.'
92
- when 1
93
- option.first
94
- else
95
- raise ArgumentError, 'Argument has multiple entries. Use Mocha::ParameterMatchers#has_entries instead.'
96
- end
84
+ private
85
+
86
+ # @private
87
+ def parse_option(option)
88
+ case option
89
+ when Hash
90
+ case option.length
91
+ when 0
92
+ raise ArgumentError, 'Argument has no entries.'
93
+ when 1
94
+ option.first
97
95
  else
98
- raise ArgumentError, 'Argument is not a Hash.'
96
+ raise ArgumentError, 'Argument has multiple entries. Use Mocha::ParameterMatchers#has_entries instead.'
99
97
  end
98
+ else
99
+ raise ArgumentError, 'Argument is not a Hash.'
100
100
  end
101
101
  end
102
-
103
- provide_deprecated_access_to(:HasEntry)
104
102
  end
105
103
  end
@@ -1,38 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/parameter_matchers/base'
2
- require 'mocha/parameter_matchers/deprecations'
3
4
 
4
5
  module Mocha
5
6
  module ParameterMatchers
6
- module Methods
7
- # Matches +Hash+ containing +key+.
8
- #
9
- # @param [Object] key expected key.
10
- # @return [HasKey] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- #
14
- # @example Actual parameter contains entry with expected key.
15
- # object = mock()
16
- # object.expects(:method_1).with(has_key('key_1'))
17
- # object.method_1('key_1' => 1, 'key_2' => 2)
18
- # # no error raised
19
- #
20
- # @example Actual parameter does not contain entry with expected key.
21
- # object = mock()
22
- # object.expects(:method_1).with(has_key('key_1'))
23
- # object.method_1('key_2' => 2)
24
- # # error raised, because method_1 was not called with Hash containing key: 'key_1'
25
- #
26
- def has_key(key) # rubocop:disable Naming/PredicateName
27
- HasKey.new(key)
28
- end
7
+ # Matches +Hash+ containing +key+.
8
+ #
9
+ # @param [Object] key expected key.
10
+ # @return [HasKey] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ #
14
+ # @example Actual parameter contains entry with expected key.
15
+ # object = mock()
16
+ # object.expects(:method_1).with(has_key('key_1'))
17
+ # object.method_1('key_1' => 1, 'key_2' => 2)
18
+ # # no error raised
19
+ #
20
+ # @example Actual parameter does not contain entry with expected key.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(has_key('key_1'))
23
+ # object.method_1('key_2' => 2)
24
+ # # error raised, because method_1 was not called with Hash containing key: 'key_1'
25
+ #
26
+ def has_key(key) # rubocop:disable Naming/PredicateName
27
+ HasKey.new(key)
29
28
  end
30
29
 
31
- define_deprecated_matcher_method(:has_key)
32
-
33
30
  # Parameter matcher which matches when actual parameter contains +Hash+ entry with expected key.
34
31
  class HasKey
35
- include BaseMethods
32
+ include Base
36
33
 
37
34
  # @private
38
35
  def initialize(key)
@@ -43,6 +40,7 @@ module Mocha
43
40
  def matches?(available_parameters)
44
41
  parameter = available_parameters.shift
45
42
  return false unless parameter.respond_to?(:keys)
43
+
46
44
  parameter.keys.any? { |key| @key.to_matcher.matches?([key]) }
47
45
  end
48
46
 
@@ -51,7 +49,5 @@ module Mocha
51
49
  "has_key(#{@key.mocha_inspect})"
52
50
  end
53
51
  end
54
-
55
- provide_deprecated_access_to(:HasKey)
56
52
  end
57
53
  end
@@ -1,38 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/parameter_matchers/base'
2
- require 'mocha/parameter_matchers/deprecations'
3
4
 
4
5
  module Mocha
5
6
  module ParameterMatchers
6
- module Methods
7
- # Matches +Hash+ containing +keys+.
8
- #
9
- # @param [*Array<Object>] keys expected keys.
10
- # @return [HasKeys] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- #
14
- # @example Actual parameter contains entry with expected keys.
15
- # object = mock()
16
- # object.expects(:method_1).with(has_keys(:key_1, :key_2))
17
- # object.method_1(:key_1 => 1, :key_2 => 2, :key_3 => 3)
18
- # # no error raised
19
- #
20
- # @example Actual parameter does not contain all expected keys.
21
- # object = mock()
22
- # object.expects(:method_1).with(has_keys(:key_1, :key_2))
23
- # object.method_1(:key_2 => 2)
24
- # # error raised, because method_1 was not called with Hash containing key: :key_1
25
- #
26
- def has_keys(*keys) # rubocop:disable Naming/PredicateName
27
- HasKeys.new(*keys)
28
- end
7
+ # Matches +Hash+ containing +keys+.
8
+ #
9
+ # @param [*Array<Object>] keys expected keys.
10
+ # @return [HasKeys] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ #
14
+ # @example Actual parameter contains entry with expected keys.
15
+ # object = mock()
16
+ # object.expects(:method_1).with(has_keys(:key_1, :key_2))
17
+ # object.method_1(:key_1 => 1, :key_2 => 2, :key_3 => 3)
18
+ # # no error raised
19
+ #
20
+ # @example Actual parameter does not contain all expected keys.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(has_keys(:key_1, :key_2))
23
+ # object.method_1(:key_2 => 2)
24
+ # # error raised, because method_1 was not called with Hash containing key: :key_1
25
+ #
26
+ def has_keys(*keys) # rubocop:disable Naming/PredicateName
27
+ HasKeys.new(*keys)
29
28
  end
30
29
 
31
- define_deprecated_matcher_method(:has_keys)
32
-
33
30
  # Parameter matcher which matches when actual parameter contains +Hash+ with all expected keys.
34
31
  class HasKeys
35
- include BaseMethods
32
+ include Base
36
33
 
37
34
  # @private
38
35
  def initialize(*keys)
@@ -53,10 +50,8 @@ module Mocha
53
50
 
54
51
  # @private
55
52
  def mocha_inspect
56
- "has_keys(#{@keys.mocha_inspect(false)})"
53
+ "has_keys(#{@keys.mocha_inspect(wrapped: false)})"
57
54
  end
58
55
  end
59
-
60
- provide_deprecated_access_to(:HasKeys)
61
56
  end
62
57
  end
@@ -1,38 +1,35 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/parameter_matchers/base'
2
- require 'mocha/parameter_matchers/deprecations'
3
4
 
4
5
  module Mocha
5
6
  module ParameterMatchers
6
- module Methods
7
- # Matches +Hash+ containing +value+.
8
- #
9
- # @param [Object] value expected value.
10
- # @return [HasValue] parameter matcher.
11
- #
12
- # @see Expectation#with
13
- #
14
- # @example Actual parameter contains entry with expected value.
15
- # object = mock()
16
- # object.expects(:method_1).with(has_value(1))
17
- # object.method_1('key_1' => 1, 'key_2' => 2)
18
- # # no error raised
19
- #
20
- # @example Actual parameter does not contain entry with expected value.
21
- # object = mock()
22
- # object.expects(:method_1).with(has_value(1))
23
- # object.method_1('key_2' => 2)
24
- # # error raised, because method_1 was not called with Hash containing value: 1
25
- #
26
- def has_value(value) # rubocop:disable Naming/PredicateName
27
- HasValue.new(value)
28
- end
7
+ # Matches +Hash+ containing +value+.
8
+ #
9
+ # @param [Object] value expected value.
10
+ # @return [HasValue] parameter matcher.
11
+ #
12
+ # @see Expectation#with
13
+ #
14
+ # @example Actual parameter contains entry with expected value.
15
+ # object = mock()
16
+ # object.expects(:method_1).with(has_value(1))
17
+ # object.method_1('key_1' => 1, 'key_2' => 2)
18
+ # # no error raised
19
+ #
20
+ # @example Actual parameter does not contain entry with expected value.
21
+ # object = mock()
22
+ # object.expects(:method_1).with(has_value(1))
23
+ # object.method_1('key_2' => 2)
24
+ # # error raised, because method_1 was not called with Hash containing value: 1
25
+ #
26
+ def has_value(value) # rubocop:disable Naming/PredicateName
27
+ HasValue.new(value)
29
28
  end
30
29
 
31
- define_deprecated_matcher_method(:has_value)
32
-
33
30
  # Parameter matcher which matches when actual parameter contains +Hash+ entry with expected value.
34
31
  class HasValue
35
- include BaseMethods
32
+ include Base
36
33
 
37
34
  # @private
38
35
  def initialize(value)
@@ -43,6 +40,7 @@ module Mocha
43
40
  def matches?(available_parameters)
44
41
  parameter = available_parameters.shift
45
42
  return false unless parameter.respond_to?(:values)
43
+
46
44
  parameter.values.any? { |value| @value.to_matcher.matches?([value]) }
47
45
  end
48
46
 
@@ -51,7 +49,5 @@ module Mocha
51
49
  "has_value(#{@value.mocha_inspect})"
52
50
  end
53
51
  end
54
-
55
- provide_deprecated_access_to(:HasValue)
56
52
  end
57
53
  end