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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e64d5427fb1829eee6958310ca322357d6fc0a8fa0d7856ea6b616edbf326c45
|
|
4
|
+
data.tar.gz: 052c4fc645bb95c2f09f9d66e1ef6a9025aea478b90accd1fc932de0151f684b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: efd275f6eb30e58383bc67037953e8f02ffa0d0d9ca920ec492267184fe6f3ac8a4765b074d39d8d3b1de38d1e11a374262e3e4a4a3b3e7ee7877f8aba0529b0
|
|
7
|
+
data.tar.gz: 22b0a2331dc25358032dd83823de41c884a752eb69e80b21befc1d79f931cee4dcc13cf5d40f04bddc3e9ef894b1d2168b90daf3fc89935ed0cd85b41e1b3611
|
data/.rubocop.yml
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rake
|
|
3
|
+
|
|
1
4
|
inherit_from: .rubocop_todo.yml
|
|
2
5
|
|
|
6
|
+
inherit_mode:
|
|
7
|
+
merge:
|
|
8
|
+
- Include
|
|
9
|
+
|
|
3
10
|
AllCops:
|
|
4
|
-
TargetRubyVersion: 2.2
|
|
11
|
+
TargetRubyVersion: 2.2
|
|
12
|
+
|
|
13
|
+
Include:
|
|
14
|
+
- '**/Gemfile.*'
|
|
15
|
+
|
|
16
|
+
Exclude:
|
|
17
|
+
- '**/Gemfile*.lock'
|
|
18
|
+
|
|
19
|
+
NewCops: enable
|
|
5
20
|
|
|
6
21
|
# Even the reference in the documentation suggests that you should prefer
|
|
7
22
|
# `alias_method` vs `alias`, so I don't understand why that isn't the default.
|
|
@@ -50,9 +65,58 @@ Layout/AccessModifierIndentation:
|
|
|
50
65
|
Enabled: false
|
|
51
66
|
|
|
52
67
|
# Allow long comment lines, e.g. YARD documentation
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
Layout/LineLength:
|
|
69
|
+
AllowedPatterns: ['\A\s*#']
|
|
55
70
|
|
|
56
71
|
# It's not possible to set TargetRubyVersion to Ruby < v2.2
|
|
57
72
|
Gemspec/RequiredRubyVersion:
|
|
58
73
|
Enabled: false
|
|
74
|
+
|
|
75
|
+
# It can be useful to violate this cop in tests in order to be more explicit
|
|
76
|
+
Lint/UselessTimes:
|
|
77
|
+
Exclude:
|
|
78
|
+
- 'test/**/*.rb'
|
|
79
|
+
|
|
80
|
+
# It can be useful to violate this cop in tests
|
|
81
|
+
Lint/EmptyClass:
|
|
82
|
+
Exclude:
|
|
83
|
+
- 'test/**/*.rb'
|
|
84
|
+
|
|
85
|
+
# It can be useful to violate this cop in tests when testing methods that accept a block
|
|
86
|
+
Lint/EmptyBlock:
|
|
87
|
+
Exclude:
|
|
88
|
+
- 'test/**/*.rb'
|
|
89
|
+
|
|
90
|
+
# There are a mix of styles in the tests and so I don't think it's worth enforcing for now
|
|
91
|
+
Naming/VariableNumber:
|
|
92
|
+
Exclude:
|
|
93
|
+
- 'test/**/*.rb'
|
|
94
|
+
|
|
95
|
+
# These methods from Ruby core are legitimately overridden in the tests
|
|
96
|
+
Style/OptionalBooleanParameter:
|
|
97
|
+
AllowedMethods:
|
|
98
|
+
- respond_to?
|
|
99
|
+
- public_methods
|
|
100
|
+
- protected_methods
|
|
101
|
+
- private_methods
|
|
102
|
+
- public_instance_methods
|
|
103
|
+
- protected_instance_methods
|
|
104
|
+
- private_instance_methods
|
|
105
|
+
|
|
106
|
+
# This cop is useful for required environment variables, but not for optional ones
|
|
107
|
+
Style/FetchEnvVar:
|
|
108
|
+
AllowedVars:
|
|
109
|
+
- MOCHA_RUN_INTEGRATION_TESTS
|
|
110
|
+
|
|
111
|
+
Naming/FileName:
|
|
112
|
+
ExpectMatchingDefinition: true
|
|
113
|
+
CheckDefinitionPathHierarchyRoots:
|
|
114
|
+
- test/unit
|
|
115
|
+
- test/acceptance
|
|
116
|
+
Exclude:
|
|
117
|
+
- lib/mocha/version.rb
|
|
118
|
+
- lib/mocha/minitest.rb
|
|
119
|
+
- lib/mocha/test_unit.rb
|
|
120
|
+
- lib/mocha/ruby_version.rb
|
|
121
|
+
- lib/mocha/macos_version.rb
|
|
122
|
+
- test/test_helper.rb
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2025-01-03 14:37:32 UTC using RuboCop version 1.69.2.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
9
|
+
# Offense count: 34
|
|
10
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
10
11
|
Metrics/AbcSize:
|
|
11
|
-
Max:
|
|
12
|
+
Max: 27
|
|
12
13
|
|
|
13
|
-
# Offense count:
|
|
14
|
-
# Configuration parameters: CountComments.
|
|
14
|
+
# Offense count: 28
|
|
15
|
+
# Configuration parameters: CountComments, CountAsOne.
|
|
15
16
|
Metrics/ClassLength:
|
|
16
|
-
Max:
|
|
17
|
+
Max: 381
|
|
17
18
|
|
|
18
|
-
# Offense count:
|
|
19
|
-
# Configuration parameters:
|
|
19
|
+
# Offense count: 2
|
|
20
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
21
|
+
Metrics/CyclomaticComplexity:
|
|
22
|
+
Max: 9
|
|
23
|
+
|
|
24
|
+
# Offense count: 200
|
|
25
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
20
26
|
Metrics/MethodLength:
|
|
21
|
-
Max:
|
|
27
|
+
Max: 27
|
|
28
|
+
|
|
29
|
+
# Offense count: 3
|
|
30
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
31
|
+
Metrics/PerceivedComplexity:
|
|
32
|
+
Max: 10
|
|
22
33
|
|
|
23
|
-
# Offense count:
|
|
24
|
-
#
|
|
34
|
+
# Offense count: 68
|
|
35
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
36
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
25
37
|
# URISchemes: http, https
|
|
26
|
-
|
|
27
|
-
Max:
|
|
38
|
+
Layout/LineLength:
|
|
39
|
+
Max: 173
|
data/Gemfile
CHANGED
|
@@ -2,34 +2,18 @@ source 'https://rubygems.org'
|
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
gem '
|
|
8
|
-
else
|
|
5
|
+
group :development do
|
|
6
|
+
gem 'introspection', '~> 0.0.1'
|
|
7
|
+
gem 'minitest'
|
|
9
8
|
gem 'rake'
|
|
10
|
-
end
|
|
11
|
-
# rubocop:enable Bundler/DuplicatedGem
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
gem 'psych', '< 4'
|
|
18
|
-
end
|
|
10
|
+
if RUBY_ENGINE == 'jruby'
|
|
11
|
+
# Workaround for https://github.com/jruby/jruby/issues/8488
|
|
12
|
+
gem 'jar-dependencies', '~> 0.4.1'
|
|
13
|
+
end
|
|
19
14
|
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
if RUBY_VERSION >= '2.2.0'
|
|
25
|
-
gem 'jaro_winkler', '>= 1.5.5'
|
|
26
|
-
gem 'rubocop', '> 0.56', '<= 0.58.2'
|
|
27
|
-
end
|
|
28
|
-
if RUBY_ENGINE == 'jruby'
|
|
29
|
-
# Workaround for https://github.com/jruby/jruby/issues/8488
|
|
30
|
-
gem 'jar-dependencies', '~> 0.4.1'
|
|
31
|
-
end
|
|
32
|
-
if ENV['MOCHA_GENERATE_DOCS']
|
|
33
|
-
gem 'redcarpet'
|
|
34
|
-
gem 'yard'
|
|
15
|
+
if ENV['MOCHA_GENERATE_DOCS']
|
|
16
|
+
gem 'redcarpet'
|
|
17
|
+
gem 'yard'
|
|
18
|
+
end
|
|
35
19
|
end
|
data/README.md
CHANGED
|
@@ -292,10 +292,9 @@ If you want, Mocha can generate a warning or raise an exception when:
|
|
|
292
292
|
|
|
293
293
|
See the [documentation](https://mocha.jamesmead.org/Mocha/Configuration.html) for `Mocha::Configuration` for further details.
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* `debug`: Enables a debug mode which will output backtraces for each deprecation warning. This is useful for finding where in the test suite the deprecated calls are.
|
|
295
|
+
### Debugging
|
|
296
|
+
|
|
297
|
+
Mocha provides some extra output to help with debugging when the standard Ruby debug option (`-d`) is set.
|
|
299
298
|
|
|
300
299
|
### Semantic versioning
|
|
301
300
|
|
data/RELEASE.md
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
# Release Notes
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.0-rc.1
|
|
4
4
|
|
|
5
5
|
### External changes
|
|
6
6
|
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Extract `ParameterMatchers::BaseMethods` module and deprecate inheriting from `ParameterMatchers::Base` class (0ddfbe4b)
|
|
23
|
-
* Move matcher builder methods into `ParameterMatchers::Methods` module and only include that module into `API` (2de41423)
|
|
24
|
-
* Provide deprecated access to matcher builder methods when including `ParameterMatchers` module (299488e1)
|
|
25
|
-
* Provide deprecated access to matcher classes, e.g. `ParameterMatchers::Equals`, from within tests/specs (dcced1b4)
|
|
7
|
+
* Improvements to docs for cardinality-related methods (#700)
|
|
8
|
+
* Drop support for Ruby v2.1 (#628 & #695)
|
|
9
|
+
* Improve gemspec description (#692 & #696)
|
|
10
|
+
* Remove docs for `use_test_unit_gem` option (eaf03493)
|
|
11
|
+
* Correct docs for `MOCHA_OPTIONS` "debug" value (69ef41c0)
|
|
12
|
+
* Use built-in Ruby debug option vs custom module (#714 & #715)
|
|
13
|
+
* Enable strict keyword argument matching by default in Ruby >= v3 (#697 & #718)
|
|
14
|
+
* Use Ruby v1.9 Hash syntax in `Hash#mocha_inspect` used in failure messages (#651 & #719)
|
|
15
|
+
* Improve `#mocha_inspect` for empty keyword argument `Hash` (#588 & #720) - thanks to @herwinw for reporting
|
|
16
|
+
* Improve error if `Mockery.teardown` called before `Mockery.setup` (#611, #646 & #721) - thanks to @riniculous for reporting
|
|
17
|
+
* Freeze string literals (#722)
|
|
18
|
+
* Remove support for running tests with Minitest < v5 (#727)
|
|
19
|
+
* Allow keyword arguments to match an expectation expecting *only* positional arguments (#593 & #732) - thanks to @seandilda
|
|
20
|
+
for reporting
|
|
26
21
|
|
|
27
22
|
### Internal changes
|
|
28
23
|
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*
|
|
33
|
-
*
|
|
24
|
+
* Add `Expectation#thrice` (#701) - thanks to @andrewn617
|
|
25
|
+
* Add `base64` to Gemfile for Ruby >= v3.3.0 to avoid warning (8c49314c & a76330d6)
|
|
26
|
+
* Include custom Gemfiles in Rubocop linting (04063f0d)
|
|
27
|
+
* Use ruby:3.4.0-rc1 vs ruby:3.4.0-preview2 in CI in preparation for the Ruby v3.4 release (b2127407)
|
|
28
|
+
* Add `ostruct` to Gemfile for Ruby >= v3.4.0 to avoid warning (2b05e09e)
|
|
29
|
+
* Add Ruby v3.4 to CI build matrix (#708)
|
|
30
|
+
* Fix Ruby v3.4 warnings in ObjectInspectTest (#709 & #710)
|
|
31
|
+
* Rubocop-related improvements (#702 & #705)
|
|
32
|
+
* Consistently use development group in Gemfiles (#706 & #716)
|
|
33
|
+
* Add missing requires for 'mocha/ruby_version' (7f99db69)
|
|
34
|
+
* Convert `ParameterMatchers::Base` class -> module (#712 & #723)
|
|
35
|
+
* Enable `ExpectMatchingDefinition` option on `Naming/FileName` cop (#726)
|
|
36
|
+
* Remove duplicate `DefaultReceiverTest` (39d99954)
|
|
37
|
+
* Improvements to keyword argument matching tests (#730)
|
|
38
|
+
* Improvements to keyword argument matcher unit test (#731)
|
|
34
39
|
|
|
35
40
|
## 2.7.1
|
|
36
41
|
|
data/Rakefile
CHANGED
|
@@ -6,9 +6,10 @@ require 'bundler/setup'
|
|
|
6
6
|
|
|
7
7
|
require 'rake/testtask'
|
|
8
8
|
begin
|
|
9
|
-
# Only available with
|
|
9
|
+
# Only available with `gemfiles/Gemfile.rubocop`
|
|
10
10
|
require 'rubocop/rake_task'
|
|
11
|
-
rescue LoadError
|
|
11
|
+
rescue LoadError
|
|
12
|
+
warn "Unable to load 'rubocop/rake_task', but continuing anyway" if $DEBUG
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
desc 'Run all linters and tests'
|
|
@@ -81,6 +82,7 @@ namespace 'test' do # rubocop:disable Metrics/BlockLength
|
|
|
81
82
|
end
|
|
82
83
|
end
|
|
83
84
|
|
|
85
|
+
desc 'Run linters'
|
|
84
86
|
task 'lint' do
|
|
85
87
|
if defined?(RuboCop::RakeTask)
|
|
86
88
|
RuboCop::RakeTask.new
|
|
@@ -90,7 +92,6 @@ task 'lint' do
|
|
|
90
92
|
end
|
|
91
93
|
end
|
|
92
94
|
|
|
93
|
-
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
94
95
|
def benchmark_test_case(klass, iterations)
|
|
95
96
|
require 'benchmark'
|
|
96
97
|
require 'mocha/detection/minitest'
|
|
@@ -119,8 +120,6 @@ def benchmark_test_case(klass, iterations)
|
|
|
119
120
|
Benchmark.realtime { iterations.times { Test::Unit::UI::Console::TestRunner.run(klass, @silent_option) } }
|
|
120
121
|
end
|
|
121
122
|
end
|
|
122
|
-
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
123
|
-
|
|
124
123
|
if ENV['MOCHA_GENERATE_DOCS']
|
|
125
124
|
require 'yard'
|
|
126
125
|
|
|
@@ -134,10 +133,12 @@ if ENV['MOCHA_GENERATE_DOCS']
|
|
|
134
133
|
task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
|
|
135
134
|
end
|
|
136
135
|
|
|
136
|
+
desc 'Ensure custom domain remains in place for docs on GitHub Pages'
|
|
137
137
|
task 'checkout_docs_cname' do
|
|
138
138
|
`git checkout docs/CNAME`
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
+
desc 'Ensure custom JavaScript files remain in place for docs on GitHub Pages'
|
|
141
142
|
task 'checkout_docs_js' do
|
|
142
143
|
`git checkout docs/js/app.js`
|
|
143
144
|
`git checkout docs/js/jquery.js`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mocha
|
|
4
|
+
class AnyInstanceReceiver
|
|
5
|
+
def initialize(klass)
|
|
6
|
+
@klass = klass
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def mocks
|
|
10
|
+
klass = @klass
|
|
11
|
+
mocks = []
|
|
12
|
+
while klass
|
|
13
|
+
mocha = klass.any_instance.mocha(instantiate: false)
|
|
14
|
+
mocks << mocha if mocha
|
|
15
|
+
klass = klass.superclass
|
|
16
|
+
end
|
|
17
|
+
mocks
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/mocha/api.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'mocha/ruby_version'
|
|
2
4
|
require 'mocha/parameter_matchers'
|
|
3
5
|
require 'mocha/hooks'
|
|
@@ -32,13 +34,13 @@ module Mocha
|
|
|
32
34
|
# sheep.chew
|
|
33
35
|
# sheep.foo # => raises NoMethodError exception
|
|
34
36
|
module API
|
|
35
|
-
include ParameterMatchers
|
|
37
|
+
include ParameterMatchers
|
|
36
38
|
include Hooks
|
|
37
39
|
|
|
38
40
|
# @private
|
|
39
41
|
def self.included(_mod)
|
|
40
|
-
Object.
|
|
41
|
-
Class.
|
|
42
|
+
Object.include Mocha::ObjectMethods
|
|
43
|
+
Class.include Mocha::ClassMethods
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
# @private
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Mocha
|
|
2
4
|
class ArgumentIterator
|
|
3
5
|
def initialize(argument)
|
|
4
6
|
@argument = argument
|
|
5
7
|
end
|
|
6
8
|
|
|
7
|
-
def each
|
|
9
|
+
def each(&block)
|
|
8
10
|
if @argument.is_a?(Hash)
|
|
9
|
-
@argument.each
|
|
10
|
-
yield method_name, return_value
|
|
11
|
-
end
|
|
11
|
+
@argument.each(&block)
|
|
12
12
|
else
|
|
13
|
-
|
|
13
|
+
block.call(@argument)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/mocha/cardinality.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Mocha
|
|
2
4
|
class Cardinality
|
|
3
5
|
INFINITY = 1 / 0.0
|
|
@@ -58,7 +60,6 @@ module Mocha
|
|
|
58
60
|
@invocations.any? || maximum.zero?
|
|
59
61
|
end
|
|
60
62
|
|
|
61
|
-
# rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
62
63
|
def anticipated_times
|
|
63
64
|
if allowed_any_number_of_times?
|
|
64
65
|
'allowed any number of times'
|
|
@@ -74,7 +75,6 @@ module Mocha
|
|
|
74
75
|
"expected between #{required} and #{count(maximum)}"
|
|
75
76
|
end
|
|
76
77
|
end
|
|
77
|
-
# rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
78
78
|
|
|
79
79
|
def invoked_times
|
|
80
80
|
"invoked #{count(@invocations.size)}"
|
data/lib/mocha/central.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Mocha
|
|
2
4
|
class Central
|
|
3
5
|
class Null < self
|
|
@@ -23,12 +25,14 @@ module Mocha
|
|
|
23
25
|
|
|
24
26
|
def stub(method)
|
|
25
27
|
return if stubba_methods.detect { |m| m.matches?(method) }
|
|
28
|
+
|
|
26
29
|
method.stub
|
|
27
30
|
stubba_methods.push(method)
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
def unstub(method)
|
|
31
34
|
return unless (existing = stubba_methods.detect { |m| m.matches?(method) })
|
|
35
|
+
|
|
32
36
|
existing.unstub
|
|
33
37
|
stubba_methods.delete(existing)
|
|
34
38
|
end
|
data/lib/mocha/class_methods.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'mocha/mockery'
|
|
2
4
|
require 'mocha/any_instance_method'
|
|
3
5
|
|
|
@@ -10,7 +12,7 @@ module Mocha
|
|
|
10
12
|
@stubba_object = klass
|
|
11
13
|
end
|
|
12
14
|
|
|
13
|
-
def mocha(instantiate
|
|
15
|
+
def mocha(instantiate: true)
|
|
14
16
|
if instantiate
|
|
15
17
|
@mocha ||= Mocha::Mockery.instance.mock_impersonating_any_instance_of(@stubba_object)
|
|
16
18
|
else
|
|
@@ -46,17 +48,16 @@ module Mocha
|
|
|
46
48
|
if frozen?
|
|
47
49
|
raise StubbingError.new("can't stub method on frozen object: #{mocha_inspect}.any_instance", caller)
|
|
48
50
|
end
|
|
51
|
+
|
|
49
52
|
@any_instance ||= AnyInstance.new(self)
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
# @private
|
|
53
|
-
|
|
54
|
-
def __method_visibility__(method, include_public_methods = true)
|
|
56
|
+
def __method_visibility__(method, include_public_methods: true)
|
|
55
57
|
(include_public_methods && public_method_defined?(method) && :public) ||
|
|
56
58
|
(protected_method_defined?(method) && :protected) ||
|
|
57
59
|
(private_method_defined?(method) && :private)
|
|
58
60
|
end
|
|
59
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
60
61
|
alias_method :__method_exists__?, :__method_visibility__
|
|
61
62
|
end
|
|
62
63
|
end
|