mocha 1.15.0 → 2.0.0.alpha.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -1
- data/Gemfile +3 -3
- data/RELEASE.md +42 -0
- data/Rakefile +12 -7
- data/lib/mocha/api.rb +5 -65
- data/lib/mocha/configuration.rb +30 -108
- data/lib/mocha/expectation.rb +62 -7
- data/lib/mocha/inspect.rb +2 -2
- data/lib/mocha/integration/mini_test.rb +10 -38
- data/lib/mocha/integration/test_unit/adapter.rb +1 -1
- data/lib/mocha/integration/test_unit.rb +10 -31
- data/lib/mocha/invocation.rb +2 -15
- data/lib/mocha/minitest.rb +1 -4
- data/lib/mocha/mock.rb +13 -9
- data/lib/mocha/parameter_matchers/base.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +0 -1
- data/lib/mocha/parameter_matchers/instance_methods.rb +10 -1
- data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +64 -0
- data/lib/mocha/parameters_matcher.rb +3 -3
- data/lib/mocha/ruby_version.rb +1 -9
- data/lib/mocha/stubbed_method.rb +3 -39
- data/lib/mocha/test_unit.rb +1 -4
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +1 -1
- metadata +10 -28
- data/init.rb +0 -1
- data/lib/mocha/integration/mini_test/nothing.rb +0 -19
- data/lib/mocha/integration/mini_test/version_13.rb +0 -54
- data/lib/mocha/integration/mini_test/version_140.rb +0 -54
- data/lib/mocha/integration/mini_test/version_141.rb +0 -65
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +0 -65
- data/lib/mocha/integration/mini_test/version_200.rb +0 -66
- data/lib/mocha/integration/mini_test/version_201_to_222.rb +0 -66
- data/lib/mocha/integration/mini_test/version_2110_to_2111.rb +0 -70
- data/lib/mocha/integration/mini_test/version_2112_to_320.rb +0 -73
- data/lib/mocha/integration/mini_test/version_230_to_2101.rb +0 -68
- data/lib/mocha/integration/test_unit/gem_version_200.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_203_to_220.rb +0 -62
- data/lib/mocha/integration/test_unit/gem_version_230_to_250.rb +0 -68
- data/lib/mocha/integration/test_unit/nothing.rb +0 -19
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +0 -63
- data/lib/mocha/integration.rb +0 -11
- 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
|
-
|
20
|
-
|
21
|
-
ruby_version = Gem::Version.new(RUBY_VERSION.dup)
|
9
|
+
target = Detection::TestUnit.testcase
|
10
|
+
return false unless target
|
22
11
|
|
23
|
-
|
12
|
+
test_unit_version = Gem::Version.new(Detection::TestUnit.version)
|
24
13
|
Debug.puts "Detected Test::Unit version: #{test_unit_version}"
|
25
14
|
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
37
|
-
|
38
|
-
|
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
|
data/lib/mocha/invocation.rb
CHANGED
@@ -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
|
-
|
26
|
-
|
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
|
data/lib/mocha/minitest.rb
CHANGED
@@ -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
|
-
|
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'
|
@@ -308,9 +309,12 @@ module Mocha
|
|
308
309
|
end
|
309
310
|
|
310
311
|
# @private
|
311
|
-
|
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)
|
@@ -383,14 +387,14 @@ module Mocha
|
|
383
387
|
end
|
384
388
|
|
385
389
|
def check_expiry
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
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
|
@@ -3,7 +3,7 @@ module Mocha
|
|
3
3
|
# @abstract Subclass and implement +#matches?+ and +#mocha_inspect+ to define a custom matcher. Also add a suitably named instance method to {ParameterMatchers} to build an instance of the new matcher c.f. {#equals}.
|
4
4
|
class Base
|
5
5
|
# @private
|
6
|
-
def to_matcher
|
6
|
+
def to_matcher(_expectation = nil)
|
7
7
|
self
|
8
8
|
end
|
9
9
|
|
@@ -1,11 +1,12 @@
|
|
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
|
5
6
|
# @private
|
6
7
|
module InstanceMethods
|
7
8
|
# @private
|
8
|
-
def to_matcher
|
9
|
+
def to_matcher(_expectation = nil)
|
9
10
|
Mocha::ParameterMatchers::Equals.new(self)
|
10
11
|
end
|
11
12
|
end
|
@@ -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(expectation = nil)
|
25
|
+
Mocha::ParameterMatchers::PositionalOrKeywordHash.new(self, expectation)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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, expectation)
|
10
|
+
@value = value
|
11
|
+
@expectation = expectation
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches?(available_parameters)
|
15
|
+
parameter, is_last_parameter = extract_parameter(available_parameters)
|
16
|
+
return false unless parameter == @value
|
17
|
+
|
18
|
+
if is_last_parameter && !same_type_of_hash?(parameter, @value)
|
19
|
+
return false if Mocha.configuration.strict_keyword_argument_matching?
|
20
|
+
|
21
|
+
deprecation_warning(parameter, @value) if Mocha::RUBY_V27_PLUS
|
22
|
+
end
|
23
|
+
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def mocha_inspect
|
28
|
+
@value.mocha_inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def extract_parameter(available_parameters)
|
34
|
+
[available_parameters.shift, available_parameters.empty?]
|
35
|
+
end
|
36
|
+
|
37
|
+
def same_type_of_hash?(actual, expected)
|
38
|
+
ruby2_keywords_hash?(actual) == ruby2_keywords_hash?(expected)
|
39
|
+
end
|
40
|
+
|
41
|
+
def deprecation_warning(actual, expected)
|
42
|
+
details1 = "Expectation #{expectation_definition} expected #{hash_type(expected)} (#{expected.mocha_inspect}),".squeeze(' ')
|
43
|
+
details2 = "but received #{hash_type(actual)} (#{actual.mocha_inspect})."
|
44
|
+
sentence1 = 'These will stop matching when strict keyword argument matching is enabled.'
|
45
|
+
sentence2 = 'See the documentation for Mocha::Configuration#strict_keyword_argument_matching=.'
|
46
|
+
Deprecation.warning([details1, details2, sentence1, sentence2].join(' '))
|
47
|
+
end
|
48
|
+
|
49
|
+
def hash_type(hash)
|
50
|
+
ruby2_keywords_hash?(hash) ? 'keyword arguments' : 'positional hash'
|
51
|
+
end
|
52
|
+
|
53
|
+
def ruby2_keywords_hash?(hash)
|
54
|
+
hash.is_a?(Hash) && ::Hash.ruby2_keywords_hash?(hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
def expectation_definition
|
58
|
+
return nil unless @expectation
|
59
|
+
|
60
|
+
"defined at #{@expectation.definition_location}"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -3,8 +3,9 @@ require 'mocha/parameter_matchers'
|
|
3
3
|
|
4
4
|
module Mocha
|
5
5
|
class ParametersMatcher
|
6
|
-
def initialize(expected_parameters = [ParameterMatchers::AnyParameters.new], &matching_block)
|
6
|
+
def initialize(expected_parameters = [ParameterMatchers::AnyParameters.new], expectation = nil, &matching_block)
|
7
7
|
@expected_parameters = expected_parameters
|
8
|
+
@expectation = expectation
|
8
9
|
@matching_block = matching_block
|
9
10
|
end
|
10
11
|
|
@@ -23,12 +24,11 @@ module Mocha
|
|
23
24
|
def mocha_inspect
|
24
25
|
signature = matchers.mocha_inspect
|
25
26
|
signature = signature.gsub(/^\[|\]$/, '')
|
26
|
-
signature = signature.gsub(/^\{|\}$/, '') if matchers.length == 1
|
27
27
|
"(#{signature})"
|
28
28
|
end
|
29
29
|
|
30
30
|
def matchers
|
31
|
-
@expected_parameters.map(
|
31
|
+
@expected_parameters.map { |p| p.to_matcher(@expectation) }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/mocha/ruby_version.rb
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
require 'mocha/deprecation'
|
2
|
-
|
3
1
|
module Mocha
|
4
|
-
|
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
|
data/lib/mocha/stubbed_method.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/mocha/test_unit.rb
CHANGED
@@ -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
|
-
|
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
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 = '>=
|
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:
|
4
|
+
version: 2.0.0.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-18 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
|
@@ -139,7 +121,7 @@ licenses:
|
|
139
121
|
- MIT
|
140
122
|
- BSD-2-Clause
|
141
123
|
metadata: {}
|
142
|
-
post_install_message:
|
124
|
+
post_install_message:
|
143
125
|
rdoc_options: []
|
144
126
|
require_paths:
|
145
127
|
- lib
|
@@ -147,15 +129,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
129
|
requirements:
|
148
130
|
- - ">="
|
149
131
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
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:
|
137
|
+
version: 1.3.1
|
156
138
|
requirements: []
|
157
|
-
rubygems_version: 3.
|
158
|
-
signing_key:
|
139
|
+
rubygems_version: 3.3.3
|
140
|
+
signing_key:
|
159
141
|
specification_version: 4
|
160
142
|
summary: Mocking and stubbing library
|
161
143
|
test_files: []
|
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
|