mocha 2.8.2 → 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.
- checksums.yaml +4 -4
- data/.rubocop.yml +67 -3
- data/.rubocop_todo.yml +25 -13
- data/Gemfile +11 -27
- data/README.md +3 -4
- data/RELEASE.md +30 -25
- data/Rakefile +6 -5
- data/gemfiles/Gemfile.minitest.latest +3 -3
- data/gemfiles/Gemfile.rubocop +9 -0
- data/gemfiles/Gemfile.test-unit.latest +3 -3
- data/lib/mocha/any_instance_method.rb +2 -0
- data/lib/mocha/any_instance_receiver.rb +20 -0
- data/lib/mocha/api.rb +5 -3
- data/lib/mocha/argument_iterator.rb +5 -5
- data/lib/mocha/backtrace_filter.rb +2 -0
- data/lib/mocha/{block_matcher.rb → block_matchers.rb} +2 -0
- data/lib/mocha/cardinality.rb +2 -2
- data/lib/mocha/central.rb +4 -0
- data/lib/mocha/change_state_side_effect.rb +2 -0
- data/lib/mocha/class_methods.rb +5 -4
- data/lib/mocha/configuration.rb +19 -42
- data/lib/mocha/default_name.rb +15 -0
- data/lib/mocha/default_receiver.rb +13 -0
- data/lib/mocha/deprecation.rb +15 -9
- data/lib/mocha/detection/minitest.rb +2 -0
- data/lib/mocha/detection/test_unit.rb +4 -1
- data/lib/mocha/error_with_filtered_backtrace.rb +2 -0
- data/lib/mocha/exception_raiser.rb +3 -0
- data/lib/mocha/expectation.rb +59 -25
- data/lib/mocha/expectation_error.rb +2 -0
- data/lib/mocha/expectation_error_factory.rb +2 -0
- data/lib/mocha/expectation_list.rb +2 -0
- data/lib/mocha/hooks.rb +2 -0
- data/lib/mocha/impersonating_any_instance_name.rb +13 -0
- data/lib/mocha/impersonating_name.rb +13 -0
- data/lib/mocha/in_state_ordering_constraint.rb +2 -0
- data/lib/mocha/inspect.rb +13 -10
- data/lib/mocha/instance_method.rb +2 -0
- data/lib/mocha/integration/assertion_counter.rb +2 -0
- data/lib/mocha/integration/minitest/adapter.rb +4 -3
- data/lib/mocha/integration/minitest.rb +4 -3
- data/lib/mocha/integration/monkey_patcher.rb +4 -2
- data/lib/mocha/integration/test_unit/adapter.rb +3 -0
- data/lib/mocha/integration/test_unit.rb +4 -3
- data/lib/mocha/invocation.rb +9 -6
- data/lib/mocha/logger.rb +2 -0
- data/lib/mocha/macos_version.rb +2 -0
- data/lib/mocha/method_matcher.rb +2 -0
- data/lib/mocha/minitest.rb +2 -1
- data/lib/mocha/mock.rb +8 -8
- data/lib/mocha/mockery.rb +16 -6
- data/lib/mocha/name.rb +13 -0
- data/lib/mocha/not_initialized_error.rb +2 -0
- data/lib/mocha/object_methods.rb +7 -5
- data/lib/mocha/object_receiver.rb +20 -0
- data/lib/mocha/parameter_matchers/all_of.rb +23 -28
- data/lib/mocha/parameter_matchers/any_of.rb +29 -34
- data/lib/mocha/parameter_matchers/any_parameters.rb +21 -26
- data/lib/mocha/parameter_matchers/anything.rb +18 -23
- data/lib/mocha/parameter_matchers/base.rb +5 -23
- data/lib/mocha/parameter_matchers/equals.rb +24 -29
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +23 -28
- data/lib/mocha/parameter_matchers/has_entries.rb +24 -29
- data/lib/mocha/parameter_matchers/has_entry.rb +68 -70
- data/lib/mocha/parameter_matchers/has_key.rb +25 -29
- data/lib/mocha/parameter_matchers/has_keys.rb +25 -30
- data/lib/mocha/parameter_matchers/has_value.rb +25 -29
- data/lib/mocha/parameter_matchers/includes.rb +65 -73
- data/lib/mocha/parameter_matchers/instance_methods.rb +5 -3
- data/lib/mocha/parameter_matchers/instance_of.rb +24 -29
- data/lib/mocha/parameter_matchers/is_a.rb +25 -30
- data/lib/mocha/parameter_matchers/kind_of.rb +24 -29
- data/lib/mocha/parameter_matchers/not.rb +24 -29
- data/lib/mocha/parameter_matchers/optionally.rb +35 -40
- data/lib/mocha/parameter_matchers/positional_or_keyword_hash.rb +39 -19
- data/lib/mocha/parameter_matchers/regexp_matches.rb +25 -29
- data/lib/mocha/parameter_matchers/responds_with.rb +48 -53
- data/lib/mocha/parameter_matchers/yaml_equivalent.rb +23 -28
- data/lib/mocha/parameter_matchers.rb +4 -6
- data/lib/mocha/parameters_matcher.rb +9 -1
- data/lib/mocha/raised_exception.rb +2 -0
- data/lib/mocha/return_values.rb +2 -0
- data/lib/mocha/ruby_version.rb +3 -0
- data/lib/mocha/sequence.rb +2 -0
- data/lib/mocha/single_return_value.rb +1 -1
- data/lib/mocha/state_machine.rb +2 -0
- data/lib/mocha/stubbed_method.rb +9 -2
- data/lib/mocha/stubbing_error.rb +2 -0
- data/lib/mocha/test_unit.rb +2 -1
- data/lib/mocha/thrower.rb +2 -0
- data/lib/mocha/thrown_object.rb +2 -0
- data/lib/mocha/version.rb +3 -1
- data/lib/mocha/yield_parameters.rb +2 -0
- data/lib/mocha.rb +5 -0
- data/mocha.gemspec +10 -4
- metadata +17 -16
- data/lib/mocha/debug.rb +0 -9
- data/lib/mocha/integration/minitest/exception_translation.rb +0 -14
- data/lib/mocha/is_a.rb +0 -7
- data/lib/mocha/names.rb +0 -43
- data/lib/mocha/parameter_matchers/deprecations.rb +0 -44
- data/lib/mocha/receivers.rb +0 -45
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mocha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0.pre.rc.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Mead
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
10
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ruby2_keywords
|
|
@@ -24,8 +23,9 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: 0.0.5
|
|
27
|
-
description:
|
|
28
|
-
|
|
26
|
+
description: A library for mocking and stubbing with a unified, simple and readable
|
|
27
|
+
syntax for both full & partial mocking. Built-in support for Minitest and Test::Unit.
|
|
28
|
+
Supported by many other test frameworks, e.g. RSpec.
|
|
29
29
|
email: mocha-developer@googlegroups.com
|
|
30
30
|
executables: []
|
|
31
31
|
extensions: []
|
|
@@ -44,19 +44,22 @@ files:
|
|
|
44
44
|
- RELEASE.md
|
|
45
45
|
- Rakefile
|
|
46
46
|
- gemfiles/Gemfile.minitest.latest
|
|
47
|
+
- gemfiles/Gemfile.rubocop
|
|
47
48
|
- gemfiles/Gemfile.test-unit.latest
|
|
48
49
|
- lib/mocha.rb
|
|
49
50
|
- lib/mocha/any_instance_method.rb
|
|
51
|
+
- lib/mocha/any_instance_receiver.rb
|
|
50
52
|
- lib/mocha/api.rb
|
|
51
53
|
- lib/mocha/argument_iterator.rb
|
|
52
54
|
- lib/mocha/backtrace_filter.rb
|
|
53
|
-
- lib/mocha/
|
|
55
|
+
- lib/mocha/block_matchers.rb
|
|
54
56
|
- lib/mocha/cardinality.rb
|
|
55
57
|
- lib/mocha/central.rb
|
|
56
58
|
- lib/mocha/change_state_side_effect.rb
|
|
57
59
|
- lib/mocha/class_methods.rb
|
|
58
60
|
- lib/mocha/configuration.rb
|
|
59
|
-
- lib/mocha/
|
|
61
|
+
- lib/mocha/default_name.rb
|
|
62
|
+
- lib/mocha/default_receiver.rb
|
|
60
63
|
- lib/mocha/deprecation.rb
|
|
61
64
|
- lib/mocha/detection/minitest.rb
|
|
62
65
|
- lib/mocha/detection/test_unit.rb
|
|
@@ -67,34 +70,34 @@ files:
|
|
|
67
70
|
- lib/mocha/expectation_error_factory.rb
|
|
68
71
|
- lib/mocha/expectation_list.rb
|
|
69
72
|
- lib/mocha/hooks.rb
|
|
73
|
+
- lib/mocha/impersonating_any_instance_name.rb
|
|
74
|
+
- lib/mocha/impersonating_name.rb
|
|
70
75
|
- lib/mocha/in_state_ordering_constraint.rb
|
|
71
76
|
- lib/mocha/inspect.rb
|
|
72
77
|
- lib/mocha/instance_method.rb
|
|
73
78
|
- lib/mocha/integration/assertion_counter.rb
|
|
74
79
|
- lib/mocha/integration/minitest.rb
|
|
75
80
|
- lib/mocha/integration/minitest/adapter.rb
|
|
76
|
-
- lib/mocha/integration/minitest/exception_translation.rb
|
|
77
81
|
- lib/mocha/integration/monkey_patcher.rb
|
|
78
82
|
- lib/mocha/integration/test_unit.rb
|
|
79
83
|
- lib/mocha/integration/test_unit/adapter.rb
|
|
80
84
|
- lib/mocha/invocation.rb
|
|
81
|
-
- lib/mocha/is_a.rb
|
|
82
85
|
- lib/mocha/logger.rb
|
|
83
86
|
- lib/mocha/macos_version.rb
|
|
84
87
|
- lib/mocha/method_matcher.rb
|
|
85
88
|
- lib/mocha/minitest.rb
|
|
86
89
|
- lib/mocha/mock.rb
|
|
87
90
|
- lib/mocha/mockery.rb
|
|
88
|
-
- lib/mocha/
|
|
91
|
+
- lib/mocha/name.rb
|
|
89
92
|
- lib/mocha/not_initialized_error.rb
|
|
90
93
|
- lib/mocha/object_methods.rb
|
|
94
|
+
- lib/mocha/object_receiver.rb
|
|
91
95
|
- lib/mocha/parameter_matchers.rb
|
|
92
96
|
- lib/mocha/parameter_matchers/all_of.rb
|
|
93
97
|
- lib/mocha/parameter_matchers/any_of.rb
|
|
94
98
|
- lib/mocha/parameter_matchers/any_parameters.rb
|
|
95
99
|
- lib/mocha/parameter_matchers/anything.rb
|
|
96
100
|
- lib/mocha/parameter_matchers/base.rb
|
|
97
|
-
- lib/mocha/parameter_matchers/deprecations.rb
|
|
98
101
|
- lib/mocha/parameter_matchers/equals.rb
|
|
99
102
|
- lib/mocha/parameter_matchers/equivalent_uri.rb
|
|
100
103
|
- lib/mocha/parameter_matchers/has_entries.rb
|
|
@@ -115,7 +118,6 @@ files:
|
|
|
115
118
|
- lib/mocha/parameter_matchers/yaml_equivalent.rb
|
|
116
119
|
- lib/mocha/parameters_matcher.rb
|
|
117
120
|
- lib/mocha/raised_exception.rb
|
|
118
|
-
- lib/mocha/receivers.rb
|
|
119
121
|
- lib/mocha/return_values.rb
|
|
120
122
|
- lib/mocha/ruby_version.rb
|
|
121
123
|
- lib/mocha/sequence.rb
|
|
@@ -140,7 +142,7 @@ metadata:
|
|
|
140
142
|
funding_uri: https://github.com/sponsors/floehopper
|
|
141
143
|
homepage_uri: https://mocha.jamesmead.org
|
|
142
144
|
source_code_uri: https://github.com/freerange/mocha
|
|
143
|
-
|
|
145
|
+
rubygems_mfa_required: 'true'
|
|
144
146
|
rdoc_options: []
|
|
145
147
|
require_paths:
|
|
146
148
|
- lib
|
|
@@ -148,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
148
150
|
requirements:
|
|
149
151
|
- - ">="
|
|
150
152
|
- !ruby/object:Gem::Version
|
|
151
|
-
version: '2.
|
|
153
|
+
version: '2.2'
|
|
152
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
155
|
requirements:
|
|
154
156
|
- - ">="
|
|
155
157
|
- !ruby/object:Gem::Version
|
|
156
158
|
version: '0'
|
|
157
159
|
requirements: []
|
|
158
|
-
rubygems_version: 3.
|
|
159
|
-
signing_key:
|
|
160
|
+
rubygems_version: 3.6.2
|
|
160
161
|
specification_version: 4
|
|
161
162
|
summary: Mocking and stubbing library
|
|
162
163
|
test_files: []
|
data/lib/mocha/debug.rb
DELETED
|
@@ -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
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,44 +0,0 @@
|
|
|
1
|
-
require 'mocha/deprecation'
|
|
2
|
-
require 'set'
|
|
3
|
-
|
|
4
|
-
module Mocha
|
|
5
|
-
module ParameterMatchers
|
|
6
|
-
module Deprecations
|
|
7
|
-
# @private
|
|
8
|
-
def const_missing(name)
|
|
9
|
-
if ParameterMatchers.access_deprecated?(name)
|
|
10
|
-
mod = ParameterMatchers.const_get(name)
|
|
11
|
-
Deprecation.warning(
|
|
12
|
-
"Referencing #{name} outside its namespace is deprecated. Use fully-qualified #{mod} instead."
|
|
13
|
-
)
|
|
14
|
-
mod
|
|
15
|
-
else
|
|
16
|
-
super(name)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @private
|
|
22
|
-
@classes_with_access_deprecated = Set.new
|
|
23
|
-
|
|
24
|
-
# @private
|
|
25
|
-
def self.provide_deprecated_access_to(name)
|
|
26
|
-
@classes_with_access_deprecated.add(name)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# @private
|
|
30
|
-
def self.access_deprecated?(name)
|
|
31
|
-
@classes_with_access_deprecated.include?(name)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# @private
|
|
35
|
-
def self.define_deprecated_matcher_method(name)
|
|
36
|
-
define_method(name) do |*args|
|
|
37
|
-
Deprecation.warning(
|
|
38
|
-
"Calling #{ParameterMatchers}##{name} is deprecated. Use #{Methods}##{name} instead."
|
|
39
|
-
)
|
|
40
|
-
Methods.instance_method(name).bind(self).call(*args)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
data/lib/mocha/receivers.rb
DELETED
|
@@ -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
|