mocha 2.8.0 → 3.0.0.pre.rc.2

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +37 -3
  3. data/.rubocop_todo.yml +25 -13
  4. data/.yardopts +2 -0
  5. data/Gemfile +9 -28
  6. data/README.md +3 -4
  7. data/RELEASE.md +64 -0
  8. data/Rakefile +43 -22
  9. data/gemfiles/Gemfile.minitest.latest +3 -3
  10. data/gemfiles/Gemfile.rubocop +9 -0
  11. data/gemfiles/Gemfile.test-unit.latest +3 -3
  12. data/lib/mocha/any_instance_method.rb +6 -4
  13. data/lib/mocha/any_instance_receiver.rb +20 -0
  14. data/lib/mocha/api.rb +4 -2
  15. data/lib/mocha/argument_iterator.rb +5 -5
  16. data/lib/mocha/backtrace_filter.rb +2 -0
  17. data/lib/mocha/{block_matcher.rb → block_matchers.rb} +2 -0
  18. data/lib/mocha/cardinality.rb +2 -2
  19. data/lib/mocha/central.rb +4 -0
  20. data/lib/mocha/change_state_side_effect.rb +2 -0
  21. data/lib/mocha/class_methods.rb +14 -9
  22. data/lib/mocha/configuration.rb +18 -41
  23. data/lib/mocha/default_name.rb +15 -0
  24. data/lib/mocha/default_receiver.rb +13 -0
  25. data/lib/mocha/deprecation.rb +15 -9
  26. data/lib/mocha/detection/minitest.rb +2 -0
  27. data/lib/mocha/detection/test_unit.rb +4 -1
  28. data/lib/mocha/error_with_filtered_backtrace.rb +2 -0
  29. data/lib/mocha/exception_raiser.rb +3 -0
  30. data/lib/mocha/expectation.rb +57 -23
  31. data/lib/mocha/expectation_error.rb +2 -0
  32. data/lib/mocha/expectation_error_factory.rb +2 -0
  33. data/lib/mocha/expectation_list.rb +3 -1
  34. data/lib/mocha/hooks.rb +6 -4
  35. data/lib/mocha/ignoring_warning.rb +20 -0
  36. data/lib/mocha/impersonating_any_instance_name.rb +13 -0
  37. data/lib/mocha/impersonating_name.rb +13 -0
  38. data/lib/mocha/in_state_ordering_constraint.rb +2 -0
  39. data/lib/mocha/inspect.rb +13 -10
  40. data/lib/mocha/instance_method.rb +6 -4
  41. data/lib/mocha/integration/assertion_counter.rb +2 -0
  42. data/lib/mocha/integration/minitest/adapter.rb +7 -3
  43. data/lib/mocha/integration/minitest.rb +5 -4
  44. data/lib/mocha/integration/monkey_patcher.rb +4 -2
  45. data/lib/mocha/integration/test_unit/adapter.rb +10 -4
  46. data/lib/mocha/integration/test_unit.rb +5 -4
  47. data/lib/mocha/integration.rb +5 -0
  48. data/lib/mocha/invocation.rb +9 -6
  49. data/lib/mocha/logger.rb +2 -0
  50. data/lib/mocha/macos_version.rb +2 -0
  51. data/lib/mocha/method_matcher.rb +2 -0
  52. data/lib/mocha/minitest.rb +2 -1
  53. data/lib/mocha/mock.rb +16 -12
  54. data/lib/mocha/mockery.rb +35 -17
  55. data/lib/mocha/name.rb +13 -0
  56. data/lib/mocha/not_initialized_error.rb +2 -0
  57. data/lib/mocha/object_methods.rb +20 -6
  58. data/lib/mocha/object_receiver.rb +20 -0
  59. data/lib/mocha/parameter_matchers/all_of.rb +3 -6
  60. data/lib/mocha/parameter_matchers/any_of.rb +3 -6
  61. data/lib/mocha/parameter_matchers/any_parameters.rb +3 -6
  62. data/lib/mocha/parameter_matchers/anything.rb +3 -6
  63. data/lib/mocha/parameter_matchers/{base.rb → base_methods.rb} +2 -16
  64. data/lib/mocha/parameter_matchers/equals.rb +3 -6
  65. data/lib/mocha/parameter_matchers/equivalent_uri.rb +9 -10
  66. data/lib/mocha/parameter_matchers/has_entries.rb +4 -7
  67. data/lib/mocha/parameter_matchers/has_entry.rb +5 -7
  68. data/lib/mocha/parameter_matchers/has_key.rb +5 -7
  69. data/lib/mocha/parameter_matchers/has_keys.rb +5 -8
  70. data/lib/mocha/parameter_matchers/has_value.rb +5 -7
  71. data/lib/mocha/parameter_matchers/includes.rb +6 -12
  72. data/lib/mocha/parameter_matchers/instance_methods.rb +5 -3
  73. data/lib/mocha/parameter_matchers/instance_of.rb +3 -6
  74. data/lib/mocha/parameter_matchers/is_a.rb +4 -7
  75. data/lib/mocha/parameter_matchers/kind_of.rb +3 -6
  76. data/lib/mocha/parameter_matchers/not.rb +3 -6
  77. data/lib/mocha/parameter_matchers/optionally.rb +2 -5
  78. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +39 -19
  79. data/lib/mocha/parameter_matchers/regexp_matches.rb +4 -6
  80. data/lib/mocha/parameter_matchers/responds_with.rb +3 -6
  81. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +3 -6
  82. data/lib/mocha/parameter_matchers.rb +2 -1
  83. data/lib/mocha/parameters_matcher.rb +9 -1
  84. data/lib/mocha/raised_exception.rb +2 -0
  85. data/lib/mocha/return_values.rb +2 -0
  86. data/lib/mocha/ruby_version.rb +3 -0
  87. data/lib/mocha/sequence.rb +2 -0
  88. data/lib/mocha/single_return_value.rb +1 -1
  89. data/lib/mocha/state_machine.rb +3 -1
  90. data/lib/mocha/stubbed_method.rb +15 -8
  91. data/lib/mocha/stubbing_error.rb +2 -0
  92. data/lib/mocha/test_unit.rb +2 -1
  93. data/lib/mocha/thrower.rb +2 -0
  94. data/lib/mocha/thrown_object.rb +2 -0
  95. data/lib/mocha/version.rb +3 -1
  96. data/lib/mocha/yield_parameters.rb +2 -0
  97. data/lib/mocha.rb +20 -0
  98. data/mocha.gemspec +10 -4
  99. metadata +18 -12
  100. data/lib/mocha/debug.rb +0 -9
  101. data/lib/mocha/integration/minitest/exception_translation.rb +0 -14
  102. data/lib/mocha/is_a.rb +0 -7
  103. data/lib/mocha/names.rb +0 -43
  104. data/lib/mocha/parameter_matchers/deprecations.rb +0 -46
  105. data/lib/mocha/receivers.rb +0 -45
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/single_return_value'
2
4
 
3
5
  module Mocha
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  RUBY_V27_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.7')
5
+ RUBY_V30_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('3.0')
3
6
  RUBY_V34_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('3.4')
4
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  # Used to constrain the order in which expectations can occur.
3
5
  #
@@ -1,4 +1,4 @@
1
- require 'mocha/is_a'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Mocha
4
4
  class SingleReturnValue
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  # A state machine that is used to constrain the order of invocations.
3
5
  # An invocation can be constrained to occur when a state {#is}, or {#is_not}, active.
@@ -81,7 +83,7 @@ module Mocha
81
83
  #
82
84
  # @param [String] unexpected_state_name name of unexpected state.
83
85
  # @return [StatePredicate] state predicate which, when queried, will indicate whether the {StateMachine} is *not* in the state specified by +unexpected_state_name+.
84
- def is_not(unexpected_state_name) # rubocop:disable Naming/PredicateName
86
+ def is_not(unexpected_state_name) # rubocop:disable Naming/PredicatePrefix
85
87
  StatePredicate.new(self, unexpected_state_name, 'is not') { |current, given| current != given }
86
88
  end
87
89
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ruby2_keywords'
2
4
  require 'mocha/ruby_version'
3
5
 
@@ -5,10 +7,10 @@ module Mocha
5
7
  class StubbedMethod
6
8
  PrependedModule = Class.new(Module)
7
9
 
8
- attr_reader :stubbee, :method_name
10
+ attr_reader :stubba_object, :method_name
9
11
 
10
- def initialize(stubbee, method_name)
11
- @stubbee = stubbee
12
+ def initialize(stubba_object, method_name)
13
+ @stubba_object = stubba_object
12
14
  @original_method = nil
13
15
  @original_visibility = nil
14
16
  @method_name = method_name.to_sym
@@ -23,19 +25,21 @@ module Mocha
23
25
  remove_new_method
24
26
  mock.unstub(method_name.to_sym)
25
27
  return if mock.any_expectations?
28
+
26
29
  reset_mocha
27
30
  end
28
31
 
29
32
  def mock
30
- mock_owner.mocha
33
+ stubbee.mocha
31
34
  end
32
35
 
33
36
  def reset_mocha
34
- mock_owner.reset_mocha
37
+ stubbee.reset_mocha
35
38
  end
36
39
 
37
40
  def hide_original_method
38
41
  return unless original_method_owner.__method_exists__?(method_name)
42
+
39
43
  store_original_method_visibility
40
44
  use_prepended_module_for_stub_method
41
45
  end
@@ -55,20 +59,23 @@ module Mocha
55
59
  end
56
60
 
57
61
  def matches?(other)
58
- return false unless other.class == self.class
59
- (stubbee.object_id == other.stubbee.object_id) && (method_name == other.method_name)
62
+ return false unless other.instance_of?(self.class)
63
+
64
+ (stubba_object.object_id == other.stubba_object.object_id) && # rubocop:disable Lint/IdentityComparison
65
+ (method_name == other.method_name)
60
66
  end
61
67
 
62
68
  alias_method :==, :eql?
63
69
 
64
70
  def to_s
65
- "#{stubbee}.#{method_name}"
71
+ "#{stubba_object}.#{method_name}"
66
72
  end
67
73
 
68
74
  private
69
75
 
70
76
  def retain_original_visibility(method_owner)
71
77
  return unless @original_visibility
78
+
72
79
  Module.instance_method(@original_visibility).bind(method_owner).call(method_name)
73
80
  end
74
81
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/error_with_filtered_backtrace'
2
4
 
3
5
  module Mocha
@@ -1,4 +1,5 @@
1
- require 'mocha/ruby_version'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'mocha/integration/test_unit'
3
4
 
4
5
  unless Mocha::Integration::TestUnit.activate
data/lib/mocha/thrower.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  class Thrower
3
5
  def initialize(tag, object = nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  class ThrownObject
3
5
  def initialize(tag, value = nil)
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
- VERSION = '2.8.0'.freeze
4
+ VERSION = '3.0.0-rc.2'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mocha
2
4
  class YieldParameters
3
5
  def initialize
data/lib/mocha.rb CHANGED
@@ -1 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'mocha/version'
4
+
5
+ # Mocha's top level namespace, which also provides the ability to {.configure configure} Mocha's behavior.
6
+ #
7
+ # Methods in the {API} are directly available in +Test::Unit::TestCase+, +Minitest::Unit::TestCase+.
8
+ #
9
+ # The mock creation methods are {API#mock mock}, {API#stub stub} and {API#stub_everything stub_everything}, all of which return a {Mock}
10
+ #
11
+ # A {Mock} {Mock#expects expects} or {Mock#stubs stubs} a method, which sets up (returns) an {Expectation}.
12
+ #
13
+ # An {Expectation} can be further qualified through its {Expectation fluent interface}.
14
+ #
15
+ # {ParameterMatchers} for {Expectation#with} restrict the parameter values which will match the {Expectation}.
16
+ #
17
+ # Adapters in {Integration} provide built-in support for +Minitest+ and +Test::Unit+.
18
+ #
19
+ # Integration {Hooks} enable support for other test frameworks.
20
+ module Mocha
21
+ end
data/mocha.gemspec CHANGED
@@ -2,14 +2,19 @@ lib = File.expand_path('../lib/', __FILE__)
2
2
  $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
3
  require 'mocha/version'
4
4
 
5
+ DESCRIPTION =
6
+ 'A library for mocking and stubbing with a unified, simple and readable syntax ' \
7
+ 'for both full & partial mocking. Built-in support for Minitest and Test::Unit. ' \
8
+ 'Supported by many other test frameworks, e.g. RSpec.'.freeze
9
+
5
10
  Gem::Specification.new do |s|
6
11
  s.name = 'mocha'
7
12
  s.version = Mocha::VERSION
8
13
  s.licenses = ['MIT', 'BSD-2-Clause']
9
- s.required_ruby_version = '>= 2.1'
14
+ s.required_ruby_version = '>= 2.2'
10
15
 
11
16
  s.authors = ['James Mead']
12
- s.description = 'Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.'
17
+ s.description = DESCRIPTION
13
18
  s.email = 'mocha-developer@googlegroups.com'
14
19
 
15
20
  s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -27,8 +32,9 @@ Gem::Specification.new do |s|
27
32
  'documentation_uri' => 'https://mocha.jamesmead.org/',
28
33
  'funding_uri' => 'https://github.com/sponsors/floehopper',
29
34
  'homepage_uri' => s.homepage,
30
- 'source_code_uri' => 'https://github.com/freerange/mocha'
35
+ 'source_code_uri' => 'https://github.com/freerange/mocha',
36
+ 'rubygems_mfa_required' => 'true'
31
37
  }
32
38
 
33
- s.add_runtime_dependency 'ruby2_keywords', '>= 0.0.5'
39
+ s.add_dependency 'ruby2_keywords', '>= 0.0.5'
34
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mocha
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 3.0.0.pre.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
@@ -24,8 +24,9 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.0.5
27
- description: Mocking and stubbing library with JMock/SchMock syntax, which allows
28
- mocking and stubbing of methods on real (non-mock) classes.
27
+ description: A library for mocking and stubbing with a unified, simple and readable
28
+ syntax for both full & partial mocking. Built-in support for Minitest and Test::Unit.
29
+ Supported by many other test frameworks, e.g. RSpec.
29
30
  email: mocha-developer@googlegroups.com
30
31
  executables: []
31
32
  extensions: []
@@ -44,19 +45,22 @@ files:
44
45
  - RELEASE.md
45
46
  - Rakefile
46
47
  - gemfiles/Gemfile.minitest.latest
48
+ - gemfiles/Gemfile.rubocop
47
49
  - gemfiles/Gemfile.test-unit.latest
48
50
  - lib/mocha.rb
49
51
  - lib/mocha/any_instance_method.rb
52
+ - lib/mocha/any_instance_receiver.rb
50
53
  - lib/mocha/api.rb
51
54
  - lib/mocha/argument_iterator.rb
52
55
  - lib/mocha/backtrace_filter.rb
53
- - lib/mocha/block_matcher.rb
56
+ - lib/mocha/block_matchers.rb
54
57
  - lib/mocha/cardinality.rb
55
58
  - lib/mocha/central.rb
56
59
  - lib/mocha/change_state_side_effect.rb
57
60
  - lib/mocha/class_methods.rb
58
61
  - lib/mocha/configuration.rb
59
- - lib/mocha/debug.rb
62
+ - lib/mocha/default_name.rb
63
+ - lib/mocha/default_receiver.rb
60
64
  - lib/mocha/deprecation.rb
61
65
  - lib/mocha/detection/minitest.rb
62
66
  - lib/mocha/detection/test_unit.rb
@@ -67,34 +71,36 @@ files:
67
71
  - lib/mocha/expectation_error_factory.rb
68
72
  - lib/mocha/expectation_list.rb
69
73
  - lib/mocha/hooks.rb
74
+ - lib/mocha/ignoring_warning.rb
75
+ - lib/mocha/impersonating_any_instance_name.rb
76
+ - lib/mocha/impersonating_name.rb
70
77
  - lib/mocha/in_state_ordering_constraint.rb
71
78
  - lib/mocha/inspect.rb
72
79
  - lib/mocha/instance_method.rb
80
+ - lib/mocha/integration.rb
73
81
  - lib/mocha/integration/assertion_counter.rb
74
82
  - lib/mocha/integration/minitest.rb
75
83
  - lib/mocha/integration/minitest/adapter.rb
76
- - lib/mocha/integration/minitest/exception_translation.rb
77
84
  - lib/mocha/integration/monkey_patcher.rb
78
85
  - lib/mocha/integration/test_unit.rb
79
86
  - lib/mocha/integration/test_unit/adapter.rb
80
87
  - lib/mocha/invocation.rb
81
- - lib/mocha/is_a.rb
82
88
  - lib/mocha/logger.rb
83
89
  - lib/mocha/macos_version.rb
84
90
  - lib/mocha/method_matcher.rb
85
91
  - lib/mocha/minitest.rb
86
92
  - lib/mocha/mock.rb
87
93
  - lib/mocha/mockery.rb
88
- - lib/mocha/names.rb
94
+ - lib/mocha/name.rb
89
95
  - lib/mocha/not_initialized_error.rb
90
96
  - lib/mocha/object_methods.rb
97
+ - lib/mocha/object_receiver.rb
91
98
  - lib/mocha/parameter_matchers.rb
92
99
  - lib/mocha/parameter_matchers/all_of.rb
93
100
  - lib/mocha/parameter_matchers/any_of.rb
94
101
  - lib/mocha/parameter_matchers/any_parameters.rb
95
102
  - lib/mocha/parameter_matchers/anything.rb
96
- - lib/mocha/parameter_matchers/base.rb
97
- - lib/mocha/parameter_matchers/deprecations.rb
103
+ - lib/mocha/parameter_matchers/base_methods.rb
98
104
  - lib/mocha/parameter_matchers/equals.rb
99
105
  - lib/mocha/parameter_matchers/equivalent_uri.rb
100
106
  - lib/mocha/parameter_matchers/has_entries.rb
@@ -115,7 +121,6 @@ files:
115
121
  - lib/mocha/parameter_matchers/yaml_equivalent.rb
116
122
  - lib/mocha/parameters_matcher.rb
117
123
  - lib/mocha/raised_exception.rb
118
- - lib/mocha/receivers.rb
119
124
  - lib/mocha/return_values.rb
120
125
  - lib/mocha/ruby_version.rb
121
126
  - lib/mocha/sequence.rb
@@ -140,6 +145,7 @@ metadata:
140
145
  funding_uri: https://github.com/sponsors/floehopper
141
146
  homepage_uri: https://mocha.jamesmead.org
142
147
  source_code_uri: https://github.com/freerange/mocha
148
+ rubygems_mfa_required: 'true'
143
149
  post_install_message:
144
150
  rdoc_options: []
145
151
  require_paths:
@@ -148,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
154
  requirements:
149
155
  - - ">="
150
156
  - !ruby/object:Gem::Version
151
- version: '2.1'
157
+ version: '2.2'
152
158
  required_rubygems_version: !ruby/object:Gem::Requirement
153
159
  requirements:
154
160
  - - ">="
data/lib/mocha/debug.rb DELETED
@@ -1,9 +0,0 @@
1
- module Mocha
2
- module Debug
3
- OPTIONS = (ENV['MOCHA_OPTIONS'] || '').split(',').freeze
4
-
5
- def self.puts(message)
6
- warn(message) if OPTIONS.include?('debug')
7
- end
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- require 'mocha/expectation_error'
2
-
3
- module Mocha
4
- module Integration
5
- module Minitest
6
- def self.translate(exception)
7
- return exception unless exception.is_a?(::Mocha::ExpectationError)
8
- translated_exception = ::Minitest::Assertion.new(exception.message)
9
- translated_exception.set_backtrace(exception.backtrace)
10
- translated_exception
11
- end
12
- end
13
- end
14
- end
data/lib/mocha/is_a.rb DELETED
@@ -1,7 +0,0 @@
1
- class Object
2
- # :stopdoc:
3
-
4
- alias_method :__is_a__, :is_a?
5
-
6
- # :startdoc:
7
- end
data/lib/mocha/names.rb DELETED
@@ -1,43 +0,0 @@
1
- module Mocha
2
- class ImpersonatingName
3
- def initialize(object)
4
- @object = object
5
- end
6
-
7
- def mocha_inspect
8
- @object.mocha_inspect
9
- end
10
- end
11
-
12
- class ImpersonatingAnyInstanceName
13
- def initialize(klass)
14
- @klass = klass
15
- end
16
-
17
- def mocha_inspect
18
- "#<AnyInstance:#{@klass.mocha_inspect}>"
19
- end
20
- end
21
-
22
- class Name
23
- def initialize(name)
24
- @name = name.to_s
25
- end
26
-
27
- def mocha_inspect
28
- "#<Mock:#{@name}>"
29
- end
30
- end
31
-
32
- class DefaultName
33
- def initialize(mock)
34
- @mock = mock
35
- end
36
-
37
- def mocha_inspect
38
- address = @mock.__id__ * 2
39
- address += 0x100000000 if address < 0
40
- "#<Mock:0x#{format('%<address>x', address: address)}>"
41
- end
42
- end
43
- end
@@ -1,46 +0,0 @@
1
- require 'mocha/deprecation'
2
- require 'set'
3
-
4
- module Mocha
5
- module ParameterMatchers
6
- module Methods
7
- # @private
8
- def self.included(base)
9
- base.define_singleton_method(:const_missing) do |name|
10
- if ParameterMatchers.access_deprecated?(name)
11
- Mocha::ParameterMatchers.const_get(name).tap do |mod|
12
- Deprecation.warning(
13
- "Referencing #{name} outside its namespace is deprecated. Use fully-qualified #{mod} instead."
14
- )
15
- end
16
- else
17
- super(name)
18
- end
19
- end
20
- end
21
- end
22
-
23
- # @private
24
- @classes_with_access_deprecated = Set.new
25
-
26
- # @private
27
- def self.provide_deprecated_access_to(name)
28
- @classes_with_access_deprecated.add(name)
29
- end
30
-
31
- # @private
32
- def self.access_deprecated?(name)
33
- @classes_with_access_deprecated.include?(name)
34
- end
35
-
36
- # @private
37
- def self.define_deprecated_matcher_method(name)
38
- define_method(name) do |*args|
39
- Deprecation.warning(
40
- "Calling #{ParameterMatchers}##{name} is deprecated. Use #{Methods}##{name} instead."
41
- )
42
- Methods.instance_method(name).bind(self).call(*args)
43
- end
44
- end
45
- end
46
- end
@@ -1,45 +0,0 @@
1
- module Mocha
2
- class ObjectReceiver
3
- def initialize(object)
4
- @object = object
5
- end
6
-
7
- def mocks
8
- object = @object
9
- mocks = []
10
- while object
11
- mocha = object.mocha(false)
12
- mocks << mocha if mocha
13
- object = object.is_a?(Class) ? object.superclass : nil
14
- end
15
- mocks
16
- end
17
- end
18
-
19
- class AnyInstanceReceiver
20
- def initialize(klass)
21
- @klass = klass
22
- end
23
-
24
- def mocks
25
- klass = @klass
26
- mocks = []
27
- while klass
28
- mocha = klass.any_instance.mocha(false)
29
- mocks << mocha if mocha
30
- klass = klass.superclass
31
- end
32
- mocks
33
- end
34
- end
35
-
36
- class DefaultReceiver
37
- def initialize(mock)
38
- @mock = mock
39
- end
40
-
41
- def mocks
42
- [@mock]
43
- end
44
- end
45
- end