mocha 2.0.1 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81bbdc1243eca4d6ca258b07e9738745a329022a6c70951f5cf5e613a7ac5ee4
4
- data.tar.gz: 398d1b4de44a9caaaa3a602b346e5f392356d2347127f8c70f08a0950d31b335
3
+ metadata.gz: 5107d1c391c4658db7d700e46c2f1b1e4558e4c398c44d2c63c3e45dcfda5285
4
+ data.tar.gz: 1a581c4b4ea5cabc63b58a90efa04e161e4a4304421691cd967ea17b03040df0
5
5
  SHA512:
6
- metadata.gz: 607d34cccbe3a09d7986a435b88e30612b09832e658b97ae0b7893480bc466a20cd88f47cfb818b607ed71dc6ddd29854f75ff67a9d57df20075c938f0b35ecf
7
- data.tar.gz: 8cac0563afe03c8182b5a52f14c7f1419c9024e6bceca570eeca899fb1fb139ca74dbacead46394330562f99c12ad608f07e391c48624953e23463ff076e8729
6
+ metadata.gz: 256e8515551e764d79ef1b9e3ebbffc9a0e5abdbc877ec9e4eab1f3a9bf5727f45cf03a063afe92b18dbd1c486d41d4f54be80cbdcfc9b5f83e806d1a35fd2a4
7
+ data.tar.gz: 384f5a08c9aeac9f45dcd64f3da2222dfc303ffc10c742eb3220036ca01b03d02712bfff7ad55dedfc8112e3c0425ea8fb830a78410db200225acff13f95b84e
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
@@ -1,5 +1,4 @@
1
1
  --output-dir docs
2
- --template-path yard-templates
3
2
  --no-private
4
3
  lib/mocha/api.rb
5
4
  lib/mocha/hooks.rb
data/COPYING.md CHANGED
@@ -1,3 +1,3 @@
1
- Copyright Revieworld Ltd. 2006
1
+ Copyright James Mead 2006
2
2
 
3
3
  You may use, copy and redistribute this library under the same terms as [Ruby itself](http://www.ruby-lang.org/en/LICENSE.txt) or under the [MIT license](http://www.opensource.org/licenses/MIT).
data/MIT-LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Revieworld Ltd.
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&circle-token=bc1f6576c77da43ec58badde9273fa4eb1d7f53a)](https://app.circleci.com/pipelines/github/freerange/mocha) [![Gem Version](https://badge.fury.io/rb/mocha.svg)](http://badge.fury.io/rb/mocha)
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 GOOGLE_ANALYTICS_WEB_PROPERTY_ID=UA-625523-7 rake generate_docs
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
data/RELEASE.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Release Notes
2
2
 
3
+ ## 2.0.3
4
+
5
+ ### External changes
6
+
7
+ * Fix `BacktraceFilter` to handle special characters (e242033f, #592) - thanks to @casperisfine
8
+
9
+ ### Internal changes
10
+
11
+ * Add Ruby v3.1 to the CircleCI build (3e460489)
12
+ * DRY up `regexp_matches` test (ae9fed4a)
13
+ * Fix regexp_matches tests in Ruby v3.2 (26b106a5, #590)
14
+ * Use Ruby 1.9 hash syntax (8bc0ad2f, #598, #537) - thanks to @herwinw
15
+ * Simplify storage of `MOCHA_OPTIONS` (b70507a1, #600) - thanks to @herwinw
16
+ * Pin JRuby to v9.3.9.0 in CircleCI builds (b8e6d064, #591)
17
+ * Rubocop: enable Style/FormatStringToken cop (089a688e, #603) - thanks to @herwinw
18
+ * Remove Ruby version check from `RespondsLikeTest` (21583129)
19
+ * Add Ruby v3.2 to CircleCI build (f7e17636, #601)
20
+ * Use Ruby v2.6 vs v2.2 to run lint CI job (af40b7db)
21
+ * Pin yard version to v0.9.28 to avoid `ArgumentError` (12f1eef7)
22
+ * Revert "Pin JRuby to v9.3.9.0 in CircleCI builds" (4f5bb2f0, #591)
23
+ * Remove invalid CircleCI token from badge URL (7078e76a)
24
+ * Revert "Pin yard version to v0.9.28 to avoid ArgumentError" (7c6c10c5, #609)
25
+ * Remove Google Analytics tracking code (2279c49d, #612)
26
+ * Update `MIT-LICENSE.md` (48162b4e)
27
+ * Update `COPYING.md` (f3152376)
28
+
29
+ ## 2.0.2
30
+
31
+ ### External changes
32
+
33
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,ba4d619e)
34
+
3
35
  ## 2.0.1
4
36
 
5
37
  ### External changes
@@ -41,6 +73,12 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
41
73
  * Add missing `require` statement (73493761)
42
74
  * Disable Style/Semicolon cop globally (8cd0b705)
43
75
 
76
+ ## 1.16.1
77
+
78
+ ### External changes
79
+
80
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,77af2af1)
81
+
44
82
  ## 1.16.0
45
83
 
46
84
  ### External changes
@@ -52,6 +90,12 @@ from the Ruby v1.8 standard library are no longer supported (#540,969f4845)
52
90
 
53
91
  * Remove redundant deprecation disabling in MockTest (dc8ca969)
54
92
 
93
+ ## 1.15.1
94
+
95
+ ### External changes
96
+
97
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
98
+
55
99
  ## 1.15.0
56
100
 
57
101
  ### 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 = { :output_level => Test::Unit::UI::Console::OutputLevel::SILENT }
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' => 'docs_environment') do |task|
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
- @path_pattern = Regexp.new(lib_directory)
6
+ @lib_directory = lib_directory
7
7
  end
8
8
 
9
9
  def filtered(backtrace)
10
- backtrace.reject { |location| @path_pattern.match(File.expand_path(location)) }
10
+ backtrace.reject { |location| File.expand_path(location).start_with?(@lib_directory) }
11
11
  end
12
12
  end
13
13
  end
@@ -39,13 +39,13 @@ module Mocha
39
39
  class Configuration
40
40
  # @private
41
41
  DEFAULTS = {
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
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(',').inject({}) do |hash, key|
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['debug']
6
+ warn(message) if OPTIONS.include?('debug')
10
7
  end
11
8
  end
12
9
  end
@@ -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('%x', address)} #{mocha_inspect} >"
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('%x', address)}>" : inspect
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, :before => :prepend
26
+ mod.setup :mocha_setup, before: :prepend
27
27
 
28
28
  mod.exception_handler(:handle_mocha_expectation_error)
29
29
 
30
- mod.cleanup :after => :append do
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, :after => :append
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?+ a method invocation (even if the method has been expected or stubbed).
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?+ a method invocation (even if the method has been expected or stubbed).
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, include_all)
332
+ def respond_to_missing?(symbol, _include_all)
333
333
  if @responder
334
- @responder.respond_to?(symbol, include_all)
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
@@ -37,7 +37,7 @@ module Mocha
37
37
  def mocha_inspect
38
38
  address = @mock.__id__ * 2
39
39
  address += 0x100000000 if address < 0
40
- "#<Mock:0x#{format('%x', address)}>"
40
+ "#<Mock:0x#{format('%<address>x', address: address)}>"
41
41
  end
42
42
  end
43
43
  end
@@ -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(:query => query_hash)
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
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
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: 2.0.1
4
+ version: 2.0.3
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-03 00:00:00.000000000 Z
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby2_keywords
@@ -128,8 +128,6 @@ files:
128
128
  - lib/mocha/version.rb
129
129
  - lib/mocha/yield_parameters.rb
130
130
  - mocha.gemspec
131
- - yard-templates/default/layout/html/google_analytics.erb
132
- - yard-templates/default/layout/html/setup.rb
133
131
  homepage: https://mocha.jamesmead.org
134
132
  licenses:
135
133
  - MIT
@@ -150,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
148
  - !ruby/object:Gem::Version
151
149
  version: '0'
152
150
  requirements: []
153
- rubygems_version: 3.3.3
151
+ rubygems_version: 3.4.1
154
152
  signing_key:
155
153
  specification_version: 4
156
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>
@@ -1,5 +0,0 @@
1
- def init
2
- super
3
- return unless ENV['GOOGLE_ANALYTICS_WEB_PROPERTY_ID']
4
- sections[:layout] << :google_analytics
5
- end