mocha 1.16.1 → 2.0.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile +3 -3
  4. data/RELEASE.md +25 -10
  5. data/Rakefile +12 -7
  6. data/lib/mocha/api.rb +5 -65
  7. data/lib/mocha/configuration.rb +31 -120
  8. data/lib/mocha/expectation.rb +55 -7
  9. data/lib/mocha/inspect.rb +2 -2
  10. data/lib/mocha/integration/mini_test.rb +10 -38
  11. data/lib/mocha/integration/test_unit/adapter.rb +1 -1
  12. data/lib/mocha/integration/test_unit.rb +10 -31
  13. data/lib/mocha/invocation.rb +2 -15
  14. data/lib/mocha/minitest.rb +1 -4
  15. data/lib/mocha/mock.rb +21 -17
  16. data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -1
  17. data/lib/mocha/parameter_matchers/instance_methods.rb +9 -0
  18. data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +56 -0
  19. data/lib/mocha/parameters_matcher.rb +0 -1
  20. data/lib/mocha/ruby_version.rb +1 -9
  21. data/lib/mocha/stubbed_method.rb +3 -39
  22. data/lib/mocha/test_unit.rb +1 -4
  23. data/lib/mocha/version.rb +1 -1
  24. data/mocha.gemspec +1 -1
  25. metadata +6 -24
  26. data/init.rb +0 -1
  27. data/lib/mocha/integration/mini_test/nothing.rb +0 -19
  28. data/lib/mocha/integration/mini_test/version_13.rb +0 -54
  29. data/lib/mocha/integration/mini_test/version_140.rb +0 -54
  30. data/lib/mocha/integration/mini_test/version_141.rb +0 -65
  31. data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
  32. data/lib/mocha/integration/mini_test/version_200.rb +0 -66
  33. data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
  34. data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
  35. data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
  36. data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
  37. data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
  38. data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
  39. data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
  40. data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
  41. data/lib/mocha/integration/test_unit/nothing.rb +0 -19
  42. data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
  43. data/lib/mocha/integration.rb +0 -11
  44. data/lib/mocha/setup.rb +0 -14
@@ -1,47 +1,26 @@
1
1
  require 'mocha/debug'
2
-
3
2
  require 'mocha/detection/test_unit'
4
-
5
- require 'mocha/integration/test_unit/nothing'
6
- require 'mocha/integration/test_unit/ruby_version_186_and_above'
7
- require 'mocha/integration/test_unit/gem_version_200'
8
- require 'mocha/integration/test_unit/gem_version_201_to_202'
9
- require 'mocha/integration/test_unit/gem_version_203_to_220'
10
- require 'mocha/integration/test_unit/gem_version_230_to_250'
11
3
  require 'mocha/integration/test_unit/adapter'
12
4
 
13
- require 'mocha/deprecation'
14
-
15
5
  module Mocha
16
6
  module Integration
17
7
  module TestUnit
18
8
  def self.activate
19
- return false unless Detection::TestUnit.testcase
20
- test_unit_version = Gem::Version.new(Detection::TestUnit.version)
21
- ruby_version = Gem::Version.new(RUBY_VERSION.dup)
9
+ target = Detection::TestUnit.testcase
10
+ return false unless target
22
11
 
23
- Debug.puts "Detected Ruby version: #{ruby_version}"
12
+ test_unit_version = Gem::Version.new(Detection::TestUnit.version)
24
13
  Debug.puts "Detected Test::Unit version: #{test_unit_version}"
25
14
 
26
- integration_module = [
27
- TestUnit::Adapter,
28
- TestUnit::GemVersion230To250,
29
- TestUnit::GemVersion203To220,
30
- TestUnit::GemVersion201To202,
31
- TestUnit::GemVersion200,
32
- TestUnit::RubyVersion186AndAbove,
33
- TestUnit::Nothing
34
- ].detect { |m| m.applicable_to?(test_unit_version, ruby_version) }
15
+ unless TestUnit::Adapter.applicable_to?(test_unit_version)
16
+ raise 'Versions of test-unit earlier than v2.5.1 are not supported.'
17
+ end
35
18
 
36
- unless ::Test::Unit::TestCase < integration_module
37
- unless integration_module == TestUnit::Adapter
38
- Deprecation.warning(
39
- 'Versions of test-unit earlier than v2.5.1 will not be supported in future versions of Mocha.'
40
- )
41
- end
42
- Debug.puts "Applying #{integration_module.description}"
43
- ::Test::Unit::TestCase.send(:include, integration_module)
19
+ unless target < TestUnit::Adapter
20
+ Debug.puts "Applying #{TestUnit::Adapter.description}"
21
+ target.send(:include, TestUnit::Adapter)
44
22
  end
23
+
45
24
  true
46
25
  end
47
26
  end
@@ -3,8 +3,6 @@ require 'mocha/raised_exception'
3
3
  require 'mocha/return_values'
4
4
  require 'mocha/thrown_object'
5
5
  require 'mocha/yield_parameters'
6
- require 'mocha/configuration'
7
- require 'mocha/deprecation'
8
6
 
9
7
  module Mocha
10
8
  class Invocation
@@ -22,18 +20,8 @@ module Mocha
22
20
  def call(yield_parameters = YieldParameters.new, return_values = ReturnValues.new)
23
21
  yield_parameters.next_invocation.each do |yield_args|
24
22
  @yields << ParametersMatcher.new(yield_args)
25
- if @block
26
- @block.call(*yield_args)
27
- else
28
- raise LocalJumpError unless Mocha.configuration.reinstate_undocumented_behaviour_from_v1_9?
29
- yield_args_description = ParametersMatcher.new(yield_args).mocha_inspect
30
- Deprecation.warning(
31
- "Stubbed method was instructed to yield #{yield_args_description}, but no block was given by invocation: #{call_description}.",
32
- ' This will raise a LocalJumpError in the future.',
33
- ' Use Expectation#with_block_given to constrain this expectation to match invocations supplying a block.',
34
- ' And, if necessary, add another expectation to match invocations not supplying a block.'
35
- )
36
- end
23
+ raise LocalJumpError unless @block
24
+ @block.call(*yield_args)
37
25
  end
38
26
  return_values.next(self)
39
27
  end
@@ -79,7 +67,6 @@ module Mocha
79
67
  def argument_description
80
68
  signature = arguments.mocha_inspect
81
69
  signature = signature.gsub(/^\[|\]$/, '')
82
- signature = signature.gsub(/^\{|\}$/, '') if arguments.length == 1
83
70
  "(#{signature})"
84
71
  end
85
72
  end
@@ -1,9 +1,6 @@
1
1
  require 'mocha/ruby_version'
2
2
  require 'mocha/integration/mini_test'
3
- require 'mocha/deprecation'
4
3
 
5
4
  unless Mocha::Integration::MiniTest.activate
6
- Mocha::Deprecation.warning(
7
- "MiniTest must be loaded *before* `require 'mocha/minitest'`."
8
- )
5
+ raise "MiniTest must be loaded *before* `require 'mocha/minitest'`."
9
6
  end
data/lib/mocha/mock.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'ruby2_keywords'
1
2
  require 'mocha/expectation'
2
3
  require 'mocha/expectation_list'
3
4
  require 'mocha/invocation'
@@ -182,11 +183,11 @@ module Mocha
182
183
  end
183
184
  end
184
185
 
185
- # Constrains the {Mock} instance so that it can only expect or stub methods to which +responder+ responds publicly. The constraint is only applied at method invocation time.
186
+ # Constrains the {Mock} instance so that it can only expect or stub methods to which +responder+ responds. The constraint is only applied at method invocation time.
186
187
  #
187
- # A +NoMethodError+ will be raised if the +responder+ does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
188
+ # A +NoMethodError+ will be raised if the +responder+ does not +#respond_to?+ a method invocation (even if the method has been expected or stubbed).
188
189
  #
189
- # The {Mock} instance will delegate its +#respond_to?+ method to the +responder+. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
190
+ # The {Mock} instance will delegate its +#respond_to?+ method to the +responder+.
190
191
  #
191
192
  # Note that the methods on +responder+ are never actually invoked.
192
193
  #
@@ -236,11 +237,11 @@ module Mocha
236
237
  self
237
238
  end
238
239
 
239
- # Constrains the {Mock} instance so that it can only expect or stub methods to which an instance of the +responder_class+ responds publicly. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using +Class#allocate+.
240
+ # Constrains the {Mock} instance so that it can only expect or stub methods to which an instance of the +responder_class+ responds. The constraint is only applied at method invocation time. Note that the responder instance is instantiated using +Class#allocate+.
240
241
  #
241
- # A +NoMethodError+ will be raised if the responder instance does not publicly +#respond_to?+ the invoked method (even if the method has been expected or stubbed).
242
+ # A +NoMethodError+ will be raised if the responder instance does not +#respond_to?+ a method invocation (even if the method has been expected or stubbed).
242
243
  #
243
- # The {Mock} instance will delegate its +#respond_to?+ method to the responder instance. However, the +include_all+ parameter is not passed through, so only public methods on the +responder+ will be considered.
244
+ # The {Mock} instance will delegate its +#respond_to?+ method to the responder instance.
244
245
  #
245
246
  # Note that the methods on the responder instance are never actually invoked.
246
247
  #
@@ -308,9 +309,12 @@ module Mocha
308
309
  end
309
310
 
310
311
  # @private
311
- def method_missing(symbol, *arguments, &block) # rubocop:disable Style/MethodMissingSuper
312
+ # rubocop:disable Style/MethodMissingSuper
313
+ def method_missing(symbol, *arguments, &block)
312
314
  handle_method_call(symbol, arguments, block)
313
315
  end
316
+ ruby2_keywords(:method_missing)
317
+ # rubocop:enable Style/MethodMissingSuper
314
318
 
315
319
  # @private
316
320
  def handle_method_call(symbol, arguments, block)
@@ -325,9 +329,9 @@ module Mocha
325
329
  end
326
330
 
327
331
  # @private
328
- def respond_to_missing?(symbol, _include_all)
332
+ def respond_to_missing?(symbol, include_all)
329
333
  if @responder
330
- @responder.respond_to?(symbol)
334
+ @responder.respond_to?(symbol, include_all)
331
335
  else
332
336
  @everything_stubbed || all_expectations.matches_method?(symbol)
333
337
  end
@@ -383,14 +387,14 @@ module Mocha
383
387
  end
384
388
 
385
389
  def check_expiry
386
- if @expired # rubocop:disable Style/GuardClause
387
- Deprecation.warning(
388
- "#{mocha_inspect} was instantiated in one test but it is receiving invocations within another test.",
389
- ' This can lead to unintended interactions between tests and hence unexpected test failures.',
390
- ' Ensure that every test correctly cleans up any state that it introduces.',
391
- ' A Mocha::StubbingError will be raised in this scenario in the future.'
392
- )
393
- end
390
+ return unless @expired
391
+
392
+ sentences = [
393
+ "#{mocha_inspect} was instantiated in one test but it is receiving invocations within another test.",
394
+ 'This can lead to unintended interactions between tests and hence unexpected test failures.',
395
+ 'Ensure that every test correctly cleans up any state that it introduces.'
396
+ ]
397
+ raise StubbingError.new(sentences.join(' '), caller)
394
398
  end
395
399
  end
396
400
  end
@@ -1,4 +1,3 @@
1
- require 'mocha/deprecation'
2
1
  require 'mocha/parameter_matchers/base'
3
2
  require 'uri'
4
3
  require 'cgi'
@@ -1,4 +1,5 @@
1
1
  require 'mocha/parameter_matchers/equals'
2
+ require 'mocha/parameter_matchers/positional_or_keyword_hash'
2
3
 
3
4
  module Mocha
4
5
  module ParameterMatchers
@@ -16,3 +17,11 @@ end
16
17
  class Object
17
18
  include Mocha::ParameterMatchers::InstanceMethods
18
19
  end
20
+
21
+ # @private
22
+ class Hash
23
+ # @private
24
+ def to_matcher
25
+ Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self)
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ require 'mocha/configuration'
2
+ require 'mocha/deprecation'
3
+ require 'mocha/parameter_matchers/base'
4
+
5
+ module Mocha
6
+ module ParameterMatchers
7
+ # @private
8
+ class PositionalOrKeywordHash < Base
9
+ def initialize(value)
10
+ @value = value
11
+ end
12
+
13
+ def matches?(available_parameters)
14
+ parameter, is_last_parameter = extract_parameter(available_parameters)
15
+ return false unless parameter == @value
16
+
17
+ if is_last_parameter && !same_type_of_hash?(parameter, @value)
18
+ return false if Mocha.configuration.strict_keyword_argument_matching?
19
+
20
+ deprecation_warning(parameter, @value) if Mocha::RUBY_V27_PLUS
21
+ end
22
+
23
+ true
24
+ end
25
+
26
+ def mocha_inspect
27
+ @value.mocha_inspect
28
+ end
29
+
30
+ private
31
+
32
+ def extract_parameter(available_parameters)
33
+ [available_parameters.shift, available_parameters.empty?]
34
+ end
35
+
36
+ def same_type_of_hash?(actual, expected)
37
+ ruby2_keywords_hash?(actual) == ruby2_keywords_hash?(expected)
38
+ end
39
+
40
+ def deprecation_warning(actual, expected)
41
+ details = "Expected #{hash_type(expected)} (#{expected.mocha_inspect}), but received #{hash_type(actual)} (#{actual.mocha_inspect})."
42
+ sentence1 = 'These will stop matching when strict keyword argument matching is enabled.'
43
+ sentence2 = 'See the documentation for Mocha::Configuration#strict_keyword_argument_matching=.'
44
+ Deprecation.warning([details, sentence1, sentence2].join(' '))
45
+ end
46
+
47
+ def hash_type(hash)
48
+ ruby2_keywords_hash?(hash) ? 'keyword arguments' : 'positional hash'
49
+ end
50
+
51
+ def ruby2_keywords_hash?(hash)
52
+ hash.is_a?(Hash) && ::Hash.ruby2_keywords_hash?(hash)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -23,7 +23,6 @@ module Mocha
23
23
  def mocha_inspect
24
24
  signature = matchers.mocha_inspect
25
25
  signature = signature.gsub(/^\[|\]$/, '')
26
- signature = signature.gsub(/^\{|\}$/, '') if matchers.length == 1
27
26
  "(#{signature})"
28
27
  end
29
28
 
@@ -1,11 +1,3 @@
1
- require 'mocha/deprecation'
2
-
3
1
  module Mocha
4
- RUBY_V2_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2')
5
-
6
- unless RUBY_V2_PLUS
7
- Mocha::Deprecation.warning(
8
- 'Versions of Ruby earlier than v2.0 will not be supported in future versions of Mocha.'
9
- )
10
- end
2
+ RUBY_V27_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.7')
11
3
  end
@@ -1,3 +1,4 @@
1
+ require 'ruby2_keywords'
1
2
  require 'mocha/ruby_version'
2
3
 
3
4
  module Mocha
@@ -20,7 +21,6 @@ module Mocha
20
21
 
21
22
  def unstub
22
23
  remove_new_method
23
- restore_original_method
24
24
  mock.unstub(method_name.to_sym)
25
25
  return if mock.any_expectations?
26
26
  reset_mocha
@@ -37,20 +37,7 @@ module Mocha
37
37
  def hide_original_method
38
38
  return unless original_method_owner.__method_exists__?(method_name)
39
39
  store_original_method_visibility
40
- if use_prepended_module_for_stub_method?
41
- use_prepended_module_for_stub_method
42
- else
43
- begin
44
- store_original_method
45
- # rubocop:disable Lint/HandleExceptions
46
- rescue NameError
47
- # deal with nasties like ActiveRecord::Associations::AssociationProxy
48
- end
49
- # rubocop:enable Lint/HandleExceptions
50
- if stub_method_overwrites_original_method?
51
- remove_original_method_from_stubbee
52
- end
53
- end
40
+ use_prepended_module_for_stub_method
54
41
  end
55
42
 
56
43
  def define_new_method
@@ -59,6 +46,7 @@ module Mocha
59
46
  stub_method_owner.send(:define_method, method_name) do |*args, &block|
60
47
  self_in_scope.mock.handle_method_call(method_name_in_scope, args, block)
61
48
  end
49
+ stub_method_owner.send(:ruby2_keywords, method_name)
62
50
  retain_original_visibility(stub_method_owner)
63
51
  end
64
52
 
@@ -66,18 +54,6 @@ module Mocha
66
54
  stub_method_owner.send(:remove_method, method_name)
67
55
  end
68
56
 
69
- def store_original_method
70
- @original_method = stubbee_method(method_name)
71
- end
72
-
73
- def restore_original_method
74
- return if use_prepended_module_for_stub_method?
75
- if stub_method_overwrites_original_method?
76
- original_method_owner.send(:define_method, method_name, @original_method)
77
- end
78
- retain_original_visibility(original_method_owner)
79
- end
80
-
81
57
  def matches?(other)
82
58
  return false unless other.class == self.class
83
59
  (stubbee.object_id == other.stubbee.object_id) && (method_name == other.method_name)
@@ -100,18 +76,6 @@ module Mocha
100
76
  @original_visibility = original_method_owner.__method_visibility__(method_name)
101
77
  end
102
78
 
103
- def stub_method_overwrites_original_method?
104
- @original_method && @original_method.owner == original_method_owner
105
- end
106
-
107
- def remove_original_method_from_stubbee
108
- original_method_owner.send(:remove_method, method_name)
109
- end
110
-
111
- def use_prepended_module_for_stub_method?
112
- RUBY_V2_PLUS
113
- end
114
-
115
79
  def use_prepended_module_for_stub_method
116
80
  @stub_method_owner = PrependedModule.new
117
81
  original_method_owner.__send__ :prepend, @stub_method_owner
@@ -1,9 +1,6 @@
1
1
  require 'mocha/ruby_version'
2
2
  require 'mocha/integration/test_unit'
3
- require 'mocha/deprecation'
4
3
 
5
4
  unless Mocha::Integration::TestUnit.activate
6
- Mocha::Deprecation.warning(
7
- "Test::Unit must be loaded *before* `require 'mocha/test_unit'`."
8
- )
5
+ raise "Test::Unit must be loaded *before* `require 'mocha/test_unit'`."
9
6
  end
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '1.16.1'.freeze
2
+ VERSION = '2.0.0.alpha'.freeze
3
3
  end
data/mocha.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
6
6
  s.name = 'mocha'
7
7
  s.version = Mocha::VERSION
8
8
  s.licenses = ['MIT', 'BSD-2-Clause']
9
- s.required_ruby_version = '>= 1.9'
9
+ s.required_ruby_version = '>= 2.0'
10
10
 
11
11
  s.authors = ['James Mead']
12
12
  s.description = 'Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.'
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: 1.16.1
4
+ version: 2.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-07 00:00:00.000000000 Z
11
+ date: 2022-10-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Mocking and stubbing library with JMock/SchMock syntax, which allows
14
14
  mocking and stubbing of methods on real (non-mock) classes.
@@ -31,7 +31,6 @@ files:
31
31
  - Rakefile
32
32
  - gemfiles/Gemfile.minitest.latest
33
33
  - gemfiles/Gemfile.test-unit.latest
34
- - init.rb
35
34
  - lib/mocha.rb
36
35
  - lib/mocha/any_instance_method.rb
37
36
  - lib/mocha/api.rb
@@ -57,30 +56,13 @@ files:
57
56
  - lib/mocha/in_state_ordering_constraint.rb
58
57
  - lib/mocha/inspect.rb
59
58
  - lib/mocha/instance_method.rb
60
- - lib/mocha/integration.rb
61
59
  - lib/mocha/integration/assertion_counter.rb
62
60
  - lib/mocha/integration/mini_test.rb
63
61
  - lib/mocha/integration/mini_test/adapter.rb
64
62
  - lib/mocha/integration/mini_test/exception_translation.rb
65
- - lib/mocha/integration/mini_test/nothing.rb
66
- - lib/mocha/integration/mini_test/version_13.rb
67
- - lib/mocha/integration/mini_test/version_140.rb
68
- - lib/mocha/integration/mini_test/version_141.rb
69
- - lib/mocha/integration/mini_test/version_142_to_172.rb
70
- - lib/mocha/integration/mini_test/version_200.rb
71
- - lib/mocha/integration/mini_test/version_201_to_222.rb
72
- - lib/mocha/integration/mini_test/version_2110_to_2111.rb
73
- - lib/mocha/integration/mini_test/version_2112_to_320.rb
74
- - lib/mocha/integration/mini_test/version_230_to_2101.rb
75
63
  - lib/mocha/integration/monkey_patcher.rb
76
64
  - lib/mocha/integration/test_unit.rb
77
65
  - lib/mocha/integration/test_unit/adapter.rb
78
- - lib/mocha/integration/test_unit/gem_version_200.rb
79
- - lib/mocha/integration/test_unit/gem_version_201_to_202.rb
80
- - lib/mocha/integration/test_unit/gem_version_203_to_220.rb
81
- - lib/mocha/integration/test_unit/gem_version_230_to_250.rb
82
- - lib/mocha/integration/test_unit/nothing.rb
83
- - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
84
66
  - lib/mocha/invocation.rb
85
67
  - lib/mocha/is_a.rb
86
68
  - lib/mocha/logger.rb
@@ -112,6 +94,7 @@ files:
112
94
  - lib/mocha/parameter_matchers/kind_of.rb
113
95
  - lib/mocha/parameter_matchers/not.rb
114
96
  - lib/mocha/parameter_matchers/optionally.rb
97
+ - lib/mocha/parameter_matchers/positional_or_keyword_hash.rb
115
98
  - lib/mocha/parameter_matchers/regexp_matches.rb
116
99
  - lib/mocha/parameter_matchers/responds_with.rb
117
100
  - lib/mocha/parameter_matchers/yaml_equivalent.rb
@@ -121,7 +104,6 @@ files:
121
104
  - lib/mocha/return_values.rb
122
105
  - lib/mocha/ruby_version.rb
123
106
  - lib/mocha/sequence.rb
124
- - lib/mocha/setup.rb
125
107
  - lib/mocha/single_return_value.rb
126
108
  - lib/mocha/state_machine.rb
127
109
  - lib/mocha/stubbed_method.rb
@@ -147,12 +129,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
129
  requirements:
148
130
  - - ">="
149
131
  - !ruby/object:Gem::Version
150
- version: '1.9'
132
+ version: '2.0'
151
133
  required_rubygems_version: !ruby/object:Gem::Requirement
152
134
  requirements:
153
- - - ">="
135
+ - - ">"
154
136
  - !ruby/object:Gem::Version
155
- version: '0'
137
+ version: 1.3.1
156
138
  requirements: []
157
139
  rubygems_version: 3.3.3
158
140
  signing_key:
data/init.rb DELETED
@@ -1 +0,0 @@
1
- warn 'Mocha deprecation warning: The old-style Rails plugin will not be supported in future versions of Mocha.'
@@ -1,19 +0,0 @@
1
- module Mocha
2
- module Integration
3
- module MiniTest
4
- module Nothing
5
- def self.applicable_to?(_test_unit_version, _ruby_version = nil)
6
- true
7
- end
8
-
9
- def self.description
10
- 'nothing (no MiniTest integration available)'
11
- end
12
-
13
- def self.included(_mod)
14
- raise 'No MiniTest integration available'
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,54 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/integration/mini_test/exception_translation'
4
-
5
- module Mocha
6
- module Integration
7
- module MiniTest
8
- module Version13
9
- def self.applicable_to?(mini_test_version)
10
- Gem::Requirement.new('>= 1.3.0', '<= 1.3.1').satisfied_by?(mini_test_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for MiniTest gem v1.3'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run runner
24
- assertion_counter = AssertionCounter.new(self)
25
- result = '.'
26
- begin
27
- begin
28
- @passed = nil
29
- mocha_setup
30
- self.setup
31
- self.__send__ self.name
32
- mocha_verify(assertion_counter)
33
- @passed = true
34
- rescue Exception => e
35
- @passed = false
36
- result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
37
- ensure
38
- begin
39
- self.teardown
40
- rescue Exception => e
41
- result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
42
- end
43
- end
44
- ensure
45
- mocha_teardown
46
- end
47
- result
48
- end
49
- # rubocop:enable all
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,54 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/integration/mini_test/exception_translation'
4
-
5
- module Mocha
6
- module Integration
7
- module MiniTest
8
- module Version140
9
- def self.applicable_to?(mini_test_version)
10
- Gem::Requirement.new('1.4.0').satisfied_by?(mini_test_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for MiniTest gem v1.4.0'
15
- end
16
-
17
- def self.included(mod)
18
- MonkeyPatcher.apply(mod, RunMethodPatch)
19
- end
20
-
21
- module RunMethodPatch
22
- # rubocop:disable all
23
- def run runner
24
- assertion_counter = AssertionCounter.new(self)
25
- result = '.'
26
- begin
27
- begin
28
- @passed = nil
29
- mocha_setup
30
- self.setup
31
- self.__send__ self.__name__
32
- mocha_verify(assertion_counter)
33
- @passed = true
34
- rescue Exception => e
35
- @passed = false
36
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
37
- ensure
38
- begin
39
- self.teardown
40
- rescue Exception => e
41
- result = runner.puke(self.class, self.__name__, Mocha::Integration::MiniTest.translate(e))
42
- end
43
- end
44
- ensure
45
- mocha_teardown
46
- end
47
- result
48
- end
49
- # rubocop:enable all
50
- end
51
- end
52
- end
53
- end
54
- end