mocha 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -12
- data/.yardopts +0 -1
- data/COPYING.md +2 -2
- data/Gemfile +0 -2
- data/MIT-LICENSE.md +1 -1
- data/README.md +4 -6
- data/RELEASE.md +66 -0
- data/Rakefile +2 -8
- data/lib/mocha/backtrace_filter.rb +2 -2
- data/lib/mocha/configuration.rb +7 -7
- data/lib/mocha/debug.rb +2 -5
- data/lib/mocha/expectation.rb +1 -1
- data/lib/mocha/inspect.rb +1 -1
- data/lib/mocha/integration/mini_test/adapter.rb +1 -1
- data/lib/mocha/integration/test_unit/adapter.rb +3 -3
- data/lib/mocha/mock.rb +8 -8
- data/lib/mocha/names.rb +1 -1
- data/lib/mocha/parameter_matchers/equivalent_uri.rb +1 -1
- data/lib/mocha/version.rb +1 -1
- data/mocha.gemspec +2 -0
- metadata +18 -6
- data/yard-templates/default/layout/html/google_analytics.erb +0 -8
- data/yard-templates/default/layout/html/setup.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4bd89c61177f213648b496bffa016c3546d6461da8552429560ff3f9804df4f
|
4
|
+
data.tar.gz: df6603b30f57ea57f6ba3383fc80df02ce0d94b246c35dd97b3eed80e689e717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3cb27ce0f13c163fb82a9ac9d3464ea3e0a2478a091033e1cb518a27db4dc4dad7ef16445a31cb363a31622b445413b132c7ffef29cc4b5c84183a7e951ec4d
|
7
|
+
data.tar.gz: ee6377fe60777af55832a284086920a4e1eff54824440f5ab4e9aa03c89e232034f0b0ec89abf5627de60c97d4f6405093144f37ec96217b31ba41ea125fd79b
|
data/.rubocop.yml
CHANGED
@@ -11,22 +11,10 @@ Style/Alias:
|
|
11
11
|
Style/Documentation:
|
12
12
|
Enabled: false
|
13
13
|
|
14
|
-
# Enumerable#each_with_object only available since Ruby v1.9
|
15
|
-
Style/EachWithObject:
|
16
|
-
Enabled: false
|
17
|
-
|
18
14
|
# Kernel#__dir__ has only been available since Ruby v2.0
|
19
15
|
Style/ExpandPathArguments:
|
20
16
|
Enabled: false
|
21
17
|
|
22
|
-
# Kernel#format has only supported named references since Ruby v1.9
|
23
|
-
Style/FormatStringToken:
|
24
|
-
EnforcedStyle: unannotated
|
25
|
-
|
26
|
-
# ruby19 style has only been supported since Ruby v1.9
|
27
|
-
Style/HashSyntax:
|
28
|
-
EnforcedStyle: hash_rockets
|
29
|
-
|
30
18
|
# I'm not keen on this cop, because it's easy to miss the conditional
|
31
19
|
# I think the results are particularly unhelpful when Metrics/LineLength is big
|
32
20
|
Style/IfUnlessModifier:
|
data/.yardopts
CHANGED
data/COPYING.md
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright James Mead 2006
|
2
2
|
|
3
|
-
You may use, copy and redistribute this library under the same terms as [Ruby itself](
|
3
|
+
You may use, copy and redistribute this library under the same terms as [Ruby itself](https://www.ruby-lang.org/en/about/license.txt) or under the [MIT license](https://mit-license.org/).
|
data/Gemfile
CHANGED
data/MIT-LICENSE.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006
|
1
|
+
Copyright (c) 2006 James Mead
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## Mocha [![CircleCI status of freerange/mocha](https://circleci.com/gh/freerange/mocha.svg?style=shield
|
1
|
+
## Mocha [![CircleCI status of freerange/mocha](https://circleci.com/gh/freerange/mocha.svg?style=shield)](https://app.circleci.com/pipelines/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha)
|
2
2
|
|
3
3
|
### Description
|
4
4
|
|
@@ -331,14 +331,12 @@ See this [list of contributors](https://github.com/freerange/mocha/graphs/contri
|
|
331
331
|
* Commit & push to GitHub
|
332
332
|
* Check CircleCI build is passing - https://app.circleci.com/pipelines/github/freerange/mocha
|
333
333
|
|
334
|
-
* Sign in to Google Analytics - https://analytics.google.com/analytics/web/
|
335
|
-
* Find the web property ID for floehopper (625523) > Mocha Documentation (UA-625523-7)
|
336
334
|
* Generate documentation:
|
337
335
|
|
338
336
|
```bash
|
339
337
|
$ MOCHA_GENERATE_DOCS=true bundle install
|
340
338
|
|
341
|
-
$ MOCHA_GENERATE_DOCS=true
|
339
|
+
$ MOCHA_GENERATE_DOCS=true rake generate_docs
|
342
340
|
```
|
343
341
|
* Commit documentation & push to GitHub
|
344
342
|
* Sign in to rubygems.org and find API key - https://rubygems.org/profile/edit
|
@@ -364,6 +362,6 @@ Mocha was initially harvested from projects at [Reevoo](http://www.reevoo.com/).
|
|
364
362
|
|
365
363
|
### License
|
366
364
|
|
367
|
-
© Copyright
|
365
|
+
© Copyright James Mead 2006
|
368
366
|
|
369
|
-
You may use, copy and redistribute this library under the same terms as [Ruby itself](
|
367
|
+
You may use, copy and redistribute this library under the same terms as [Ruby itself](https://www.ruby-lang.org/en/about/license.txt) or under the [MIT license](https://mit-license.org/).
|
data/RELEASE.md
CHANGED
@@ -1,5 +1,59 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## 2.1.0
|
4
|
+
|
5
|
+
### External changes
|
6
|
+
|
7
|
+
* Fix compatibility with Minitest (#614) - thanks to @kyrofa & @manewitz for reporting and to @zenspider for his input
|
8
|
+
|
9
|
+
### Internal changes
|
10
|
+
|
11
|
+
* Update URLs for links to Ruby & MIT licenses (d6470af4)
|
12
|
+
|
13
|
+
## 2.0.4
|
14
|
+
|
15
|
+
### Internal changes
|
16
|
+
|
17
|
+
* Update `README.md` (e8c21e1b)
|
18
|
+
|
19
|
+
## 2.0.3
|
20
|
+
|
21
|
+
### External changes
|
22
|
+
|
23
|
+
* Fix `BacktraceFilter` to handle special characters (e242033f, #592) - thanks to @casperisfine
|
24
|
+
|
25
|
+
### Internal changes
|
26
|
+
|
27
|
+
* Add Ruby v3.1 to the CircleCI build (3e460489)
|
28
|
+
* DRY up `regexp_matches` test (ae9fed4a)
|
29
|
+
* Fix regexp_matches tests in Ruby v3.2 (26b106a5, #590)
|
30
|
+
* Use Ruby 1.9 hash syntax (8bc0ad2f, #598, #537) - thanks to @herwinw
|
31
|
+
* Simplify storage of `MOCHA_OPTIONS` (b70507a1, #600) - thanks to @herwinw
|
32
|
+
* Pin JRuby to v9.3.9.0 in CircleCI builds (b8e6d064, #591)
|
33
|
+
* Rubocop: enable Style/FormatStringToken cop (089a688e, #603) - thanks to @herwinw
|
34
|
+
* Remove Ruby version check from `RespondsLikeTest` (21583129)
|
35
|
+
* Add Ruby v3.2 to CircleCI build (f7e17636, #601)
|
36
|
+
* Use Ruby v2.6 vs v2.2 to run lint CI job (af40b7db)
|
37
|
+
* Pin yard version to v0.9.28 to avoid `ArgumentError` (12f1eef7)
|
38
|
+
* Revert "Pin JRuby to v9.3.9.0 in CircleCI builds" (4f5bb2f0, #591)
|
39
|
+
* Remove invalid CircleCI token from badge URL (7078e76a)
|
40
|
+
* Revert "Pin yard version to v0.9.28 to avoid ArgumentError" (7c6c10c5, #609)
|
41
|
+
* Remove Google Analytics tracking code (2279c49d, #612)
|
42
|
+
* Update `MIT-LICENSE.md` (48162b4e)
|
43
|
+
* Update `COPYING.md` (f3152376)
|
44
|
+
|
45
|
+
## 2.0.2
|
46
|
+
|
47
|
+
### External changes
|
48
|
+
|
49
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,ba4d619e)
|
50
|
+
|
51
|
+
## 2.0.1
|
52
|
+
|
53
|
+
### External changes
|
54
|
+
|
55
|
+
* Fix `LoadError` when using v2.0.0 with Ruby < v2.7 by moving declaration of runtime dependency on `ruby2_keywords` gem from `Gemfile` to `mocha.gemspec` - thanks to @mishina2228 for reporting (#581, #582, cdeb0356)
|
56
|
+
|
3
57
|
## 2.0.0
|
4
58
|
|
5
59
|
### External changes
|
@@ -35,6 +89,12 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
35
89
|
* Add missing `require` statement (73493761)
|
36
90
|
* Disable Style/Semicolon cop globally (8cd0b705)
|
37
91
|
|
92
|
+
## 1.16.1
|
93
|
+
|
94
|
+
### External changes
|
95
|
+
|
96
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,77af2af1)
|
97
|
+
|
38
98
|
## 1.16.0
|
39
99
|
|
40
100
|
### External changes
|
@@ -46,6 +106,12 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
|
|
46
106
|
|
47
107
|
* Remove redundant deprecation disabling in MockTest (dc8ca969)
|
48
108
|
|
109
|
+
## 1.15.1
|
110
|
+
|
111
|
+
### External changes
|
112
|
+
|
113
|
+
* Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
|
114
|
+
|
49
115
|
## 1.15.0
|
50
116
|
|
51
117
|
### External changes
|
data/Rakefile
CHANGED
@@ -111,7 +111,7 @@ def benchmark_test_case(klass, iterations)
|
|
111
111
|
unless @silent_option
|
112
112
|
begin
|
113
113
|
load 'test/unit/ui/console/outputlevel.rb' unless defined?(Test::Unit::UI::Console::OutputLevel::SILENT)
|
114
|
-
@silent_option = { :
|
114
|
+
@silent_option = { output_level: Test::Unit::UI::Console::OutputLevel::SILENT }
|
115
115
|
rescue LoadError
|
116
116
|
@silent_option = Test::Unit::UI::SILENT
|
117
117
|
end
|
@@ -129,14 +129,8 @@ if ENV['MOCHA_GENERATE_DOCS']
|
|
129
129
|
`rm -rf ./docs`
|
130
130
|
end
|
131
131
|
|
132
|
-
task 'docs_environment' do
|
133
|
-
unless ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
|
134
|
-
puts "\nWarning: GOOGLE_ANALYTICS_WEB_PROPERTY_ID was not defined\n\n"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
132
|
desc 'Generate documentation'
|
139
|
-
YARD::Rake::YardocTask.new('yardoc'
|
133
|
+
YARD::Rake::YardocTask.new('yardoc') do |task|
|
140
134
|
task.options = ['--title', "Mocha #{Mocha::VERSION}", '--fail-on-warning']
|
141
135
|
end
|
142
136
|
|
@@ -3,11 +3,11 @@ module Mocha
|
|
3
3
|
LIB_DIRECTORY = File.expand_path(File.join(File.dirname(__FILE__), '..')) + File::SEPARATOR
|
4
4
|
|
5
5
|
def initialize(lib_directory = LIB_DIRECTORY)
|
6
|
-
@
|
6
|
+
@lib_directory = lib_directory
|
7
7
|
end
|
8
8
|
|
9
9
|
def filtered(backtrace)
|
10
|
-
backtrace.reject { |location|
|
10
|
+
backtrace.reject { |location| File.expand_path(location).start_with?(@lib_directory) }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/mocha/configuration.rb
CHANGED
@@ -39,13 +39,13 @@ module Mocha
|
|
39
39
|
class Configuration
|
40
40
|
# @private
|
41
41
|
DEFAULTS = {
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
42
|
+
stubbing_method_unnecessarily: :allow,
|
43
|
+
stubbing_method_on_non_mock_object: :allow,
|
44
|
+
stubbing_non_existent_method: :allow,
|
45
|
+
stubbing_non_public_method: :allow,
|
46
|
+
stubbing_method_on_nil: :prevent,
|
47
|
+
display_matching_invocations_on_failure: false,
|
48
|
+
strict_keyword_argument_matching: false
|
49
49
|
}.freeze
|
50
50
|
|
51
51
|
attr_reader :options
|
data/lib/mocha/debug.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
module Mocha
|
2
2
|
module Debug
|
3
|
-
OPTIONS = (ENV['MOCHA_OPTIONS'] || '').split(',').
|
4
|
-
hash[key] = true
|
5
|
-
hash
|
6
|
-
end.freeze
|
3
|
+
OPTIONS = (ENV['MOCHA_OPTIONS'] || '').split(',').freeze
|
7
4
|
|
8
5
|
def self.puts(message)
|
9
|
-
warn(message) if OPTIONS
|
6
|
+
warn(message) if OPTIONS.include?('debug')
|
10
7
|
end
|
11
8
|
end
|
12
9
|
end
|
data/lib/mocha/expectation.rb
CHANGED
@@ -674,7 +674,7 @@ module Mocha
|
|
674
674
|
def inspect
|
675
675
|
address = __id__ * 2
|
676
676
|
address += 0x100000000 if address < 0
|
677
|
-
"#<Expectation:0x#{format('
|
677
|
+
"#<Expectation:0x#{format('%<address>x', address: address)} #{mocha_inspect} >"
|
678
678
|
end
|
679
679
|
|
680
680
|
# @private
|
data/lib/mocha/inspect.rb
CHANGED
@@ -6,7 +6,7 @@ module Mocha
|
|
6
6
|
def mocha_inspect
|
7
7
|
address = __id__ * 2
|
8
8
|
address += 0x100000000 if address < 0
|
9
|
-
inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('
|
9
|
+
inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('%<address>x', address: address)}>" : inspect
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -23,16 +23,16 @@ module Mocha
|
|
23
23
|
|
24
24
|
# @private
|
25
25
|
def self.included(mod)
|
26
|
-
mod.setup :mocha_setup, :
|
26
|
+
mod.setup :mocha_setup, before: :prepend
|
27
27
|
|
28
28
|
mod.exception_handler(:handle_mocha_expectation_error)
|
29
29
|
|
30
|
-
mod.cleanup :
|
30
|
+
mod.cleanup after: :append do
|
31
31
|
assertion_counter = Integration::AssertionCounter.new(self)
|
32
32
|
mocha_verify(assertion_counter)
|
33
33
|
end
|
34
34
|
|
35
|
-
mod.teardown :mocha_teardown, :
|
35
|
+
mod.teardown :mocha_teardown, after: :append
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
data/lib/mocha/mock.rb
CHANGED
@@ -183,11 +183,11 @@ module Mocha
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
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
|
+
# 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.
|
187
187
|
#
|
188
|
-
# A +NoMethodError+ will be raised if the +responder+ does not +#respond_to?+
|
188
|
+
# 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).
|
189
189
|
#
|
190
|
-
# The {Mock} instance will delegate its +#respond_to?+ method to the +responder+.
|
190
|
+
# 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.
|
191
191
|
#
|
192
192
|
# Note that the methods on +responder+ are never actually invoked.
|
193
193
|
#
|
@@ -237,11 +237,11 @@ module Mocha
|
|
237
237
|
self
|
238
238
|
end
|
239
239
|
|
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
|
+
# 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+.
|
241
241
|
#
|
242
|
-
# A +NoMethodError+ will be raised if the responder instance does not +#respond_to?+
|
242
|
+
# 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).
|
243
243
|
#
|
244
|
-
# The {Mock} instance will delegate its +#respond_to?+ method to the responder instance.
|
244
|
+
# 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.
|
245
245
|
#
|
246
246
|
# Note that the methods on the responder instance are never actually invoked.
|
247
247
|
#
|
@@ -329,9 +329,9 @@ module Mocha
|
|
329
329
|
end
|
330
330
|
|
331
331
|
# @private
|
332
|
-
def respond_to_missing?(symbol,
|
332
|
+
def respond_to_missing?(symbol, _include_all)
|
333
333
|
if @responder
|
334
|
-
@responder.respond_to?(symbol
|
334
|
+
@responder.respond_to?(symbol)
|
335
335
|
else
|
336
336
|
@everything_stubbed || all_expectations.matches_method?(symbol)
|
337
337
|
end
|
data/lib/mocha/names.rb
CHANGED
@@ -50,7 +50,7 @@ module Mocha
|
|
50
50
|
# @private
|
51
51
|
def explode(uri)
|
52
52
|
query_hash = CGI.parse(uri.query || '')
|
53
|
-
URI::Generic::COMPONENT.inject({}) { |h, k| h.merge(k => uri.__send__(k)) }.merge(:
|
53
|
+
URI::Generic::COMPONENT.inject({}) { |h, k| h.merge(k => uri.__send__(k)) }.merge(query: query_hash)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/lib/mocha/version.rb
CHANGED
data/mocha.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mocha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Mead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby2_keywords
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.5
|
13
27
|
description: Mocking and stubbing library with JMock/SchMock syntax, which allows
|
14
28
|
mocking and stubbing of methods on real (non-mock) classes.
|
15
29
|
email: mocha-developer@googlegroups.com
|
@@ -114,8 +128,6 @@ files:
|
|
114
128
|
- lib/mocha/version.rb
|
115
129
|
- lib/mocha/yield_parameters.rb
|
116
130
|
- mocha.gemspec
|
117
|
-
- yard-templates/default/layout/html/google_analytics.erb
|
118
|
-
- yard-templates/default/layout/html/setup.rb
|
119
131
|
homepage: https://mocha.jamesmead.org
|
120
132
|
licenses:
|
121
133
|
- MIT
|
@@ -136,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
148
|
- !ruby/object:Gem::Version
|
137
149
|
version: '0'
|
138
150
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.4.1
|
140
152
|
signing_key:
|
141
153
|
specification_version: 4
|
142
154
|
summary: Mocking and stubbing library
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID'] %>"></script>
|
2
|
-
<script>
|
3
|
-
window.dataLayer = window.dataLayer || [];
|
4
|
-
function gtag(){dataLayer.push(arguments);}
|
5
|
-
gtag('js', new Date());
|
6
|
-
|
7
|
-
gtag('config', '<%= ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID'] %>');
|
8
|
-
</script>
|