mocha 1.14.0 → 1.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc815752f26d71dc07dcbe29561835e3efd005f8602ada080106a8b000491276
4
- data.tar.gz: d14e6b7be4792efe68f48eb13c084a151a6e26fe3bd30f85491a990947474ab7
3
+ metadata.gz: 5f69e06715dfda038470d522472d10e99e4de02d57f1efe4d4f81caaff7856e4
4
+ data.tar.gz: a1fae0b515f7f76108c58fc151995eaab5a03a3d034820e3853799c2f571bcda
5
5
  SHA512:
6
- metadata.gz: ca77565fde00fa34b850e95072bb32d2daf2886ddaef4ec084b6c462f4d1a8d6104ae1c5ac35f49414d3ed28527589608582b49d7ff1352388642ce710039f0d
7
- data.tar.gz: 0dab5223dde0fbd762b2a3ff92a7574f771ebcf9e8f5ec032697a3a3a7da96f6d892395b7decec1ad31512138d3f198850b5e1f20aada1885074491b13a57fb3
6
+ metadata.gz: 997c75e49d45c59eab07d55c940bf56bf94161a4b1940de46f70ab5d3c8749657de799d61ac519b85e89de9154618df5cd5d4eedcb7ab85499cf404eb5ad54f4
7
+ data.tar.gz: 90122aa4932173fc3dfc2b7295f97af05f23abb0967fc46da3a7c977ec4b16371595f21b9eeae58c50024a57e20dd3861e91ab67a405a0b29d20267a46b8800e
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2 # closest to required_ruby_version of '>= 1.8.6'
4
+ TargetRubyVersion: 2.2 # closest to required_ruby_version of '>= 1.9'
5
5
 
6
6
  # Even the reference in the documentation suggests that you should prefer
7
7
  # `alias_method` vs `alias`, so I don't understand why that isn't the default.
data/Gemfile CHANGED
@@ -3,9 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  # rubocop:disable Bundler/DuplicatedGem
6
- if RUBY_VERSION < '1.9.3'
7
- gem 'rake', '~> 10.0'
8
- elsif RUBY_VERSION < '2'
6
+ if RUBY_VERSION < '2'
9
7
  gem 'rake', '~> 12.2.1'
10
8
  elsif RUBY_VERSION < '2.2'
11
9
  gem 'rake', '~> 12.3.3'
data/README.md CHANGED
@@ -338,7 +338,7 @@ $ MOCHA_GENERATE_DOCS=true GOOGLE_ANALYTICS_WEB_PROPERTY_ID=UA-625523-7 rake gen
338
338
  * Sign in to rubygems.org and find API key - https://rubygems.org/profile/edit
339
339
 
340
340
  ```bash
341
- $ curl -u james@floehopper.org https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
341
+ $ curl -u <email-address> -H 'OTP:<one-time-password>' https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
342
342
  ```
343
343
 
344
344
  * Release gem to Rubygems:
data/RELEASE.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.15.1
4
+
5
+ ### External changes
6
+
7
+ * Fix regression in `Mock#responds_like` behaviour - thanks to @adrianna-chang-shopify for reporting (#580,#583,c586a08c)
8
+
9
+ ## 1.15.0
10
+
11
+ ### External changes
12
+
13
+ * Fix examples using mock constructor with block (1cc17667)
14
+ * Add another example for `API#sequence` (b7a7d233, #59)
15
+ * Remove support for Ruby v1.8 (ddb5d672)
16
+ * Deprecate support for Ruby versions earlier than v2.0 - thanks to @wasabigeek (#553, #555)
17
+
18
+ ### Internal changes
19
+
20
+ * Update instructions for obtaining Rubygems API key (ed9c040a)
21
+ * Consistent definitions for `respond_to?` methods (#533)
22
+ * Run test tasks before release tasks (92a1bc6e, #447)
23
+ * Fix test:performance Rake task (#538, #539)
24
+ * Tidying following removal of support for Ruby v1.8 - thanks to @nitishr (#542)
25
+ * Remove `ParametersMatcher` from `Invocation#call_description` - thanks to @wasabigeek (#543)
26
+ * Remove unnecessary splatting in Invocation - thanks to @wasabigeek (#549)
27
+ * Extract `handle_method_call` from `method_missing` - thanks to @wasabigeek (#550)
28
+
3
29
  ## 1.14.0
4
30
 
5
31
  ### External changes
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks
2
+ namespace 'rubygems' do
3
+ Bundler::GemHelper.install_tasks
4
+ end
3
5
  require 'bundler/setup'
4
6
 
5
7
  require 'rake/testtask'
@@ -18,15 +20,10 @@ task 'test' do
18
20
  end
19
21
 
20
22
  namespace 'test' do # rubocop:disable Metrics/BlockLength
21
- unit_tests = FileList['test/unit/**/*_test.rb']
22
- all_acceptance_tests = FileList['test/acceptance/*_test.rb']
23
- ruby186_incompatible_acceptance_tests = FileList['test/acceptance/stub_class_method_defined_on_*_test.rb'] + FileList['test/acceptance/stub_instance_method_defined_on_*_test.rb']
24
- ruby186_compatible_acceptance_tests = all_acceptance_tests - ruby186_incompatible_acceptance_tests
25
-
26
23
  desc 'Run unit tests'
27
24
  Rake::TestTask.new('units') do |t|
28
25
  t.libs << 'test'
29
- t.test_files = unit_tests
26
+ t.test_files = FileList['test/unit/**/*_test.rb']
30
27
  t.verbose = true
31
28
  t.warning = true
32
29
  end
@@ -34,11 +31,7 @@ namespace 'test' do # rubocop:disable Metrics/BlockLength
34
31
  desc 'Run acceptance tests'
35
32
  Rake::TestTask.new('acceptance') do |t|
36
33
  t.libs << 'test'
37
- t.test_files = if defined?(RUBY_VERSION) && (RUBY_VERSION >= '1.8.7')
38
- all_acceptance_tests
39
- else
40
- ruby186_compatible_acceptance_tests
41
- end
34
+ t.test_files = FileList['test/acceptance/*_test.rb']
42
35
  t.verbose = true
43
36
  t.warning = true
44
37
  end
@@ -100,6 +93,7 @@ def benchmark_test_case(klass, iterations)
100
93
  if defined?(MiniTest)
101
94
  minitest_version = Gem::Version.new(Mocha::Detection::MiniTest.version)
102
95
  if Gem::Requirement.new('>= 5.0.0').satisfied_by?(minitest_version)
96
+ Minitest.seed = 1
103
97
  result = Benchmark.realtime { iterations.times { |_i| klass.run(MiniTest::CompositeReporter.new) } }
104
98
  MiniTest::Runnable.runnables.delete(klass)
105
99
  result
@@ -154,4 +148,4 @@ if ENV['MOCHA_GENERATE_DOCS']
154
148
  task 'generate_docs' => %w[clobber_yardoc yardoc checkout_docs_cname checkout_docs_js]
155
149
  end
156
150
 
157
- task 'release' => 'default'
151
+ task 'release' => ['default', 'rubygems:release']
@@ -4,9 +4,5 @@ gemspec :path=>"../"
4
4
 
5
5
  group :development do
6
6
  gem "rake"
7
- if RUBY_VERSION < '1.9'
8
- gem "test-unit", "~> 2"
9
- else
10
- gem "test-unit"
11
- end
7
+ gem "test-unit"
12
8
  end
@@ -1,4 +1,3 @@
1
- require 'mocha/ruby_version'
2
1
  require 'mocha/stubbed_method'
3
2
 
4
3
  module Mocha
@@ -9,10 +8,6 @@ module Mocha
9
8
  stubbee.any_instance
10
9
  end
11
10
 
12
- def method_body(method)
13
- method
14
- end
15
-
16
11
  def stubbee_method(method_name)
17
12
  stubbee.instance_method(method_name)
18
13
  end
data/lib/mocha/api.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'mocha/ruby_version'
1
2
  require 'mocha/parameter_matchers'
2
3
  require 'mocha/hooks'
3
4
  require 'mocha/mockery'
@@ -199,11 +200,22 @@ module Mocha
199
200
  # @example Ensure methods on egg are invoked in correct order.
200
201
  # breakfast = sequence('breakfast')
201
202
  #
202
- # egg = mock('egg') do
203
- # expects(:crack).in_sequence(breakfast)
204
- # expects(:fry).in_sequence(breakfast)
205
- # expects(:eat).in_sequence(breakfast)
206
- # end
203
+ # egg = mock('egg')
204
+ # egg.expects(:crack).in_sequence(breakfast)
205
+ # egg.expects(:fry).in_sequence(breakfast)
206
+ # egg.expects(:eat).in_sequence(breakfast)
207
+ #
208
+ # @example Ensure methods across multiple objects are invoked in correct order.
209
+ # sequence = sequence(:task_order)
210
+ #
211
+ # task_one = mock("task_one")
212
+ # task_two = mock("task_two")
213
+ #
214
+ # task_one.expects(:execute).in_sequence(sequence)
215
+ # task_two.expects(:execute).in_sequence(sequence)
216
+ #
217
+ # task_one.execute
218
+ # task_two.execute
207
219
  def sequence(name)
208
220
  Sequence.new(name)
209
221
  end
@@ -226,14 +238,13 @@ module Mocha
226
238
  # @example Constrain expected invocations to occur in particular states.
227
239
  # power = states('power').starts_as('off')
228
240
  #
229
- # radio = mock('radio') do
230
- # expects(:switch_on).then(power.is('on'))
231
- # expects(:select_channel).with('BBC Radio 4').when(power.is('on'))
232
- # expects(:adjust_volume).with(+5).when(power.is('on'))
233
- # expects(:select_channel).with('BBC World Service').when(power.is('on'))
234
- # expects(:adjust_volume).with(-5).when(power.is('on'))
235
- # expects(:switch_off).then(power.is('off'))
236
- # end
241
+ # radio = mock('radio')
242
+ # radio.expects(:switch_on).then(power.is('on'))
243
+ # radio.expects(:select_channel).with('BBC Radio 4').when(power.is('on'))
244
+ # radio.expects(:adjust_volume).with(+5).when(power.is('on'))
245
+ # radio.expects(:select_channel).with('BBC World Service').when(power.is('on'))
246
+ # radio.expects(:adjust_volume).with(-5).when(power.is('on'))
247
+ # radio.expects(:switch_off).then(power.is('off'))
237
248
  def states(name)
238
249
  Mockery.instance.new_state_machine(name)
239
250
  end
@@ -26,8 +26,8 @@ module Mocha
26
26
  @stubba_object
27
27
  end
28
28
 
29
- def respond_to?(method)
30
- @stubba_object.allocate.respond_to?(method.to_sym)
29
+ def respond_to?(symbol, include_all = false)
30
+ @stubba_object.allocate.respond_to?(symbol.to_sym, include_all)
31
31
  end
32
32
 
33
33
  attr_reader :stubba_object
@@ -8,10 +8,6 @@ module Mocha
8
8
  stubbee
9
9
  end
10
10
 
11
- def method_body(method)
12
- PRE_RUBY_V19 ? proc { |*args, &block| method.call(*args, &block) } : method
13
- end
14
-
15
11
  def stubbee_method(method_name)
16
12
  stubbee._method(method_name)
17
13
  end
@@ -3,7 +3,6 @@ require 'mocha/debug'
3
3
  require 'mocha/detection/test_unit'
4
4
 
5
5
  require 'mocha/integration/test_unit/nothing'
6
- require 'mocha/integration/test_unit/ruby_version_185_and_below'
7
6
  require 'mocha/integration/test_unit/ruby_version_186_and_above'
8
7
  require 'mocha/integration/test_unit/gem_version_200'
9
8
  require 'mocha/integration/test_unit/gem_version_201_to_202'
@@ -31,7 +30,6 @@ module Mocha
31
30
  TestUnit::GemVersion201To202,
32
31
  TestUnit::GemVersion200,
33
32
  TestUnit::RubyVersion186AndAbove,
34
- TestUnit::RubyVersion185AndBelow,
35
33
  TestUnit::Nothing
36
34
  ].detect { |m| m.applicable_to?(test_unit_version, ruby_version) }
37
35
 
@@ -10,7 +10,7 @@ module Mocha
10
10
  class Invocation
11
11
  attr_reader :method_name, :block
12
12
 
13
- def initialize(mock, method_name, *arguments, &block)
13
+ def initialize(mock, method_name, arguments = [], block = nil)
14
14
  @mock = mock
15
15
  @method_name = method_name
16
16
  @arguments = arguments
@@ -55,7 +55,7 @@ module Mocha
55
55
  end
56
56
 
57
57
  def call_description
58
- description = "#{@mock.mocha_inspect}.#{@method_name}#{ParametersMatcher.new(@arguments).mocha_inspect}"
58
+ description = "#{@mock.mocha_inspect}.#{@method_name}#{argument_description}"
59
59
  description << ' { ... }' unless @block.nil?
60
60
  description
61
61
  end
@@ -73,5 +73,14 @@ module Mocha
73
73
  def full_description
74
74
  "\n - #{call_description} #{result_description}"
75
75
  end
76
+
77
+ private
78
+
79
+ def argument_description
80
+ signature = arguments.mocha_inspect
81
+ signature = signature.gsub(/^\[|\]$/, '')
82
+ signature = signature.gsub(/^\{|\}$/, '') if arguments.length == 1
83
+ "(#{signature})"
84
+ end
76
85
  end
77
86
  end
@@ -1,3 +1,4 @@
1
+ require 'mocha/ruby_version'
1
2
  require 'mocha/integration/mini_test'
2
3
  require 'mocha/deprecation'
3
4
 
data/lib/mocha/mock.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'mocha/singleton_class'
2
1
  require 'mocha/expectation'
3
2
  require 'mocha/expectation_list'
4
3
  require 'mocha/invocation'
@@ -8,7 +7,6 @@ require 'mocha/method_matcher'
8
7
  require 'mocha/parameters_matcher'
9
8
  require 'mocha/argument_iterator'
10
9
  require 'mocha/expectation_error_factory'
11
- require 'mocha/ruby_version'
12
10
 
13
11
  module Mocha
14
12
  # Traditional mock object.
@@ -165,7 +163,7 @@ module Mocha
165
163
  # @param [Array<Symbol>] method_names names of methods to unstub.
166
164
  #
167
165
  # @example Invoking an unstubbed method causes error to be raised
168
- # object = mock('mock') do
166
+ # object = mock('mock')
169
167
  # object.stubs(:stubbed_method).returns(:result_one)
170
168
  # object.stubbed_method # => :result_one
171
169
  # object.unstub(:stubbed_method)
@@ -184,11 +182,11 @@ module Mocha
184
182
  end
185
183
  end
186
184
 
187
- # 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.
185
+ # 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.
188
186
  #
189
- # A +NoMethodError+ will be raised if the +responder+ does not +#respond_to?+ a method invocation (even if the method has been expected or stubbed).
187
+ # 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).
190
188
  #
191
- # The {Mock} instance will delegate its +#respond_to?+ method to the +responder+.
189
+ # 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.
192
190
  #
193
191
  # Note that the methods on +responder+ are never actually invoked.
194
192
  #
@@ -238,11 +236,11 @@ module Mocha
238
236
  self
239
237
  end
240
238
 
241
- # 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+.
239
+ # 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+.
242
240
  #
243
- # 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).
241
+ # 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).
244
242
  #
245
- # The {Mock} instance will delegate its +#respond_to?+ method to the responder instance.
243
+ # 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.
246
244
  #
247
245
  # Note that the methods on the responder instance are never actually invoked.
248
246
  #
@@ -311,9 +309,14 @@ module Mocha
311
309
 
312
310
  # @private
313
311
  def method_missing(symbol, *arguments, &block) # rubocop:disable Style/MethodMissingSuper
312
+ handle_method_call(symbol, arguments, block)
313
+ end
314
+
315
+ # @private
316
+ def handle_method_call(symbol, arguments, block)
314
317
  check_expiry
315
318
  check_responder_responds_to(symbol)
316
- invocation = Invocation.new(self, symbol, *arguments, &block)
319
+ invocation = Invocation.new(self, symbol, arguments, block)
317
320
  if (matching_expectation_allowing_invocation = all_expectations.match_allowing_invocation(invocation))
318
321
  matching_expectation_allowing_invocation.invoke(invocation)
319
322
  elsif (matching_expectation = all_expectations.match(invocation)) || (!matching_expectation && !@everything_stubbed)
@@ -322,25 +325,14 @@ module Mocha
322
325
  end
323
326
 
324
327
  # @private
325
- def respond_to_missing?(symbol, include_private = false)
328
+ def respond_to_missing?(symbol, _include_all)
326
329
  if @responder
327
- if @responder.method(:respond_to?).arity > 1
328
- @responder.respond_to?(symbol, include_private)
329
- else
330
- @responder.respond_to?(symbol)
331
- end
330
+ @responder.respond_to?(symbol)
332
331
  else
333
332
  @everything_stubbed || all_expectations.matches_method?(symbol)
334
333
  end
335
334
  end
336
335
 
337
- if PRE_RUBY_V19
338
- # @private
339
- def respond_to?(symbol, include_private = false)
340
- respond_to_missing?(symbol, include_private)
341
- end
342
- end
343
-
344
336
  # @private
345
337
  def __verified__?(assertion_counter = nil)
346
338
  @expectations.verified?(assertion_counter)
data/lib/mocha/mockery.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'mocha/ruby_version'
2
1
  require 'mocha/central'
3
2
  require 'mocha/mock'
4
3
  require 'mocha/names'
@@ -119,10 +118,9 @@ module Mocha
119
118
  end
120
119
 
121
120
  def on_stubbing(object, method)
122
- method = PRE_RUBY_V19 ? method.to_s : method.to_sym
123
121
  signature_proc = lambda { "#{object.mocha_inspect}.#{method}" }
124
122
  check(:stubbing_non_existent_method, 'non-existent method', signature_proc) do
125
- !(object.stubba_class.__method_exists__?(method, true) || object.respond_to?(method.to_sym))
123
+ !(object.stubba_class.__method_exists__?(method, true) || object.respond_to?(method))
126
124
  end
127
125
  check(:stubbing_non_public_method, 'non-public method', signature_proc) do
128
126
  object.stubba_class.__method_exists__?(method, false)
@@ -1,4 +1,11 @@
1
+ require 'mocha/deprecation'
2
+
1
3
  module Mocha
2
- PRE_RUBY_V19 = Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9')
3
4
  RUBY_V2_PLUS = Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2')
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
4
11
  end
@@ -1,5 +1,4 @@
1
1
  require 'mocha/ruby_version'
2
- require 'mocha/singleton_class'
3
2
 
4
3
  module Mocha
5
4
  class StubbedMethod
@@ -11,7 +10,7 @@ module Mocha
11
10
  @stubbee = stubbee
12
11
  @original_method = nil
13
12
  @original_visibility = nil
14
- @method_name = PRE_RUBY_V19 ? method_name.to_s : method_name.to_sym
13
+ @method_name = method_name.to_sym
15
14
  end
16
15
 
17
16
  def stub
@@ -58,7 +57,7 @@ module Mocha
58
57
  self_in_scope = self
59
58
  method_name_in_scope = method_name
60
59
  stub_method_owner.send(:define_method, method_name) do |*args, &block|
61
- self_in_scope.mock.method_missing(method_name_in_scope, *args, &block)
60
+ self_in_scope.mock.handle_method_call(method_name_in_scope, args, block)
62
61
  end
63
62
  retain_original_visibility(stub_method_owner)
64
63
  end
@@ -74,7 +73,7 @@ module Mocha
74
73
  def restore_original_method
75
74
  return if use_prepended_module_for_stub_method?
76
75
  if stub_method_overwrites_original_method?
77
- original_method_owner.send(:define_method, method_name, method_body(@original_method))
76
+ original_method_owner.send(:define_method, method_name, @original_method)
78
77
  end
79
78
  retain_original_visibility(original_method_owner)
80
79
  end
@@ -1,3 +1,4 @@
1
+ require 'mocha/ruby_version'
1
2
  require 'mocha/integration/test_unit'
2
3
  require 'mocha/deprecation'
3
4
 
data/lib/mocha/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = '1.14.0'.freeze
2
+ VERSION = '1.15.1'.freeze
3
3
  end
data/lib/mocha.rb CHANGED
@@ -1,9 +1 @@
1
1
  require 'mocha/version'
2
- require 'mocha/ruby_version'
3
- require 'mocha/deprecation'
4
-
5
- if Mocha::PRE_RUBY_V19
6
- Mocha::Deprecation.warning(
7
- 'Versions of Ruby earlier than v1.9 will not be supported in future versions of Mocha.'
8
- )
9
- end
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 = '>= 1.8.7'
9
+ s.required_ruby_version = '>= 1.9'
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: 1.14.0
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Mead
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 1980-01-01 00:00:00.000000000 Z
11
+ date: 2022-11-07 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.
@@ -80,7 +80,6 @@ files:
80
80
  - lib/mocha/integration/test_unit/gem_version_203_to_220.rb
81
81
  - lib/mocha/integration/test_unit/gem_version_230_to_250.rb
82
82
  - lib/mocha/integration/test_unit/nothing.rb
83
- - lib/mocha/integration/test_unit/ruby_version_185_and_below.rb
84
83
  - lib/mocha/integration/test_unit/ruby_version_186_and_above.rb
85
84
  - lib/mocha/invocation.rb
86
85
  - lib/mocha/is_a.rb
@@ -124,7 +123,6 @@ files:
124
123
  - lib/mocha/sequence.rb
125
124
  - lib/mocha/setup.rb
126
125
  - lib/mocha/single_return_value.rb
127
- - lib/mocha/singleton_class.rb
128
126
  - lib/mocha/state_machine.rb
129
127
  - lib/mocha/stubbed_method.rb
130
128
  - lib/mocha/stubbing_error.rb
@@ -149,14 +147,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
147
  requirements:
150
148
  - - ">="
151
149
  - !ruby/object:Gem::Version
152
- version: 1.8.7
150
+ version: '1.9'
153
151
  required_rubygems_version: !ruby/object:Gem::Requirement
154
152
  requirements:
155
153
  - - ">="
156
154
  - !ruby/object:Gem::Version
157
155
  version: '0'
158
156
  requirements: []
159
- rubygems_version: 3.2.26
157
+ rubygems_version: 3.3.3
160
158
  signing_key:
161
159
  specification_version: 4
162
160
  summary: Mocking and stubbing library
@@ -1,61 +0,0 @@
1
- require 'mocha/integration/assertion_counter'
2
- require 'mocha/integration/monkey_patcher'
3
- require 'mocha/expectation_error'
4
-
5
- module Mocha
6
- module Integration
7
- module TestUnit
8
- module RubyVersion185AndBelow
9
- def self.applicable_to?(test_unit_version, ruby_version)
10
- Gem::Requirement.new('<= 1.2.3').satisfied_by?(test_unit_version) && Gem::Requirement.new('<= 1.8.5').satisfied_by?(ruby_version)
11
- end
12
-
13
- def self.description
14
- 'monkey patch for standard library in Ruby <= v1.8.5'
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(result)
24
- assertion_counter = AssertionCounter.new(self)
25
- yield(Test::Unit::TestCase::STARTED, name)
26
- @_result = result
27
- begin
28
- begin
29
- mocha_setup
30
- setup
31
- __send__(@method_name)
32
- mocha_verify(assertion_counter)
33
- rescue Mocha::ExpectationError => e
34
- add_failure(e.message, e.backtrace)
35
- rescue Test::Unit::AssertionFailedError => e
36
- add_failure(e.message, e.backtrace)
37
- rescue StandardError, ScriptError
38
- add_error($!)
39
- ensure
40
- begin
41
- teardown
42
- rescue Mocha::ExpectationError => e
43
- add_failure(e.message, e.backtrace)
44
- rescue Test::Unit::AssertionFailedError => e
45
- add_failure(e.message, e.backtrace)
46
- rescue StandardError, ScriptError
47
- add_error($!)
48
- end
49
- end
50
- ensure
51
- mocha_teardown
52
- end
53
- result.add_run
54
- yield(Test::Unit::TestCase::FINISHED, name)
55
- end
56
- # rubocop:enable all
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,9 +0,0 @@
1
- if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('1.9.2')
2
- unless Kernel.method_defined?(:singleton_class)
3
- module Kernel
4
- def singleton_class
5
- class << self; self; end
6
- end
7
- end
8
- end
9
- end