mocha 1.3.0 → 1.4.0

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
  SHA1:
3
- metadata.gz: 892227bf10232258f227ef350fcea251d12d38d2
4
- data.tar.gz: be2701d3a1ac024a45c95ce68868229958ae9c83
3
+ metadata.gz: b1a4df2eb13604de6b309bc453307d375c055620
4
+ data.tar.gz: 9144ebfe812beea562fc8c9ebdfb87326cb5ffa6
5
5
  SHA512:
6
- metadata.gz: 733fa5b4b62ec68012bbdbe666548f5d213e126fea1f3e2c7c6cfbbea11e10fbfb424b655c0811f39bdca98316b545d81694b6fc02d799a1d2346bfb9cc110dd
7
- data.tar.gz: b95a7905ab52b2fcf9d85597b264f1fd31f6cf5a2bc206c7af22b98c28599e46424c903128d1c1bcf4a5b4ea8b3d23d4677111bfc9544342bff0b337053943b7
6
+ metadata.gz: 1cf5b923bb4a91c6b3a1dac90aca3084229955743ae64c41cbecf561e8fd572f419d09d155ff3c9b6d0616258ca526d70677d79f9861e8987f99ee5b312bbb90
7
+ data.tar.gz: 9e635e0f0897d0437acffe0cfe4755ecae028da76513445a5b4b56ee48be878ae0070fa24d3fc8bddad02a69d790223909b936fdcdb6f53114feeec8c69cd3c4
data/README.md CHANGED
@@ -33,7 +33,7 @@ require 'mocha/test_unit'
33
33
  require 'rubygems'
34
34
  gem 'mocha'
35
35
  require 'minitest/unit'
36
- require 'mocha/mini_test'
36
+ require 'mocha/minitest'
37
37
  ```
38
38
 
39
39
  #### Bundler
@@ -59,7 +59,7 @@ gem "mocha"
59
59
 
60
60
  # Elsewhere after Bundler has loaded gems e.g. after `require 'bundler/setup'`
61
61
  require "minitest/unit"
62
- require "mocha/mini_test"
62
+ require "mocha/minitest"
63
63
  ```
64
64
 
65
65
  #### Rails
@@ -73,7 +73,7 @@ If you're loading Mocha using Bundler within a Rails application, you should set
73
73
  gem 'mocha'
74
74
 
75
75
  # At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
76
- require 'mocha/mini_test'
76
+ require 'mocha/minitest'
77
77
  ```
78
78
 
79
79
  ##### RSpec
@@ -104,7 +104,7 @@ Note: As of version 0.9.8, the Mocha plugin is not automatically setup at plugin
104
104
 
105
105
  ```ruby
106
106
  # At bottom of test_helper.rb (or at least after `require 'rails/test_help'`)
107
- require 'mocha/mini_test'
107
+ require 'mocha/minitest'
108
108
  ```
109
109
 
110
110
  #### Known Issues
data/RELEASE.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.4.0
4
+
5
+ * Fix deprecation warning for `assert_nil` in `ClassMethodTest` (#308 & #309)
6
+ * Display file and line number in deprecation warning - thanks to @chrisarcand (#310, #312 & #313)
7
+ * Rename `mocha/mini_test.rb` to `mocha/minitest.rb` - thanks to @grosser (#320 & #322)
8
+ * Fix warning when delegating to mock in Ruby 2.4 - thanks to @tjvc (#321 & #323)
9
+ * Updates to Travis CI configuration ([73af600..9732726](https://github.com/freerange/mocha/compare/73af600...9732726) & 0426e5e)
10
+
3
11
  ## 1.3.0
4
12
 
5
13
  * Ensure all tests run individually - thanks to @chrisroos (#267)
@@ -418,7 +426,7 @@ Hash with wrong number of entries.
418
426
 
419
427
  ## 0.5.0
420
428
 
421
- - Parameter Matchers - Ive added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
429
+ - Parameter Matchers - I've added a few Hamcrest-style parameter matchers which are designed to be used inside Expectation#with. The following matchers are currently available: anything(), includes(), has_key(), has_value(), has_entry(), all_of() & any_of(). More to follow soon. The idea is eventually to get rid of the nasty parameter_block option on Expectation#with.
422
430
 
423
431
  object = mock()
424
432
  object.expects(:method).with(has_key('key_1'))
@@ -1,4 +1,4 @@
1
- require 'mocha/debug'
1
+ require 'mocha/backtrace_filter'
2
2
 
3
3
  module Mocha
4
4
 
@@ -10,13 +10,16 @@ module Mocha
10
10
 
11
11
  def warning(message)
12
12
  @messages << message
13
- $stderr.puts "\n*** Mocha deprecation warning: #{message}\n\n" unless mode == :disabled
14
- $stderr.puts caller.join("\n ") if mode == :debug
13
+ unless mode == :disabled
14
+ filter = BacktraceFilter.new
15
+ location = filter.filtered(caller)[0]
16
+ $stderr.puts "Mocha deprecation warning at #{location}: #{message}"
17
+ end
15
18
  end
16
19
 
17
20
  end
18
21
 
19
- self.mode = Debug::OPTIONS['debug'] ? :debug : :enabled
22
+ self.mode = :enabled
20
23
  self.messages = []
21
24
 
22
25
  end
@@ -1,3 +1,5 @@
1
- require "mocha/integration/mini_test"
1
+ require 'mocha/deprecation'
2
2
 
3
- Mocha::Integration::MiniTest.activate
3
+ Mocha::Deprecation.warning("`require 'mocha/mini_test'` has been deprecated. Please use `require 'mocha/minitest' instead.")
4
+
5
+ require 'mocha/minitest'
@@ -0,0 +1,3 @@
1
+ require "mocha/integration/mini_test"
2
+
3
+ Mocha::Integration::MiniTest.activate
@@ -9,6 +9,7 @@ require 'mocha/unexpected_invocation'
9
9
  require 'mocha/argument_iterator'
10
10
  require 'mocha/expectation_error_factory'
11
11
  require 'mocha/deprecation'
12
+ require 'mocha/ruby_version'
12
13
 
13
14
  module Mocha
14
15
 
@@ -314,7 +315,7 @@ module Mocha
314
315
  end
315
316
 
316
317
  # @private
317
- def respond_to?(symbol, include_private = false)
318
+ def respond_to_missing?(symbol, include_private = false)
318
319
  if @responder then
319
320
  if @responder.method(:respond_to?).arity > 1
320
321
  @responder.respond_to?(symbol, include_private)
@@ -326,6 +327,13 @@ module Mocha
326
327
  end
327
328
  end
328
329
 
330
+ # @private
331
+ if PRE_RUBY_V19
332
+ def respond_to?(symbol, include_private = false)
333
+ respond_to_missing?(symbol, include_private)
334
+ end
335
+ end
336
+
329
337
  # @private
330
338
  def __verified__?(assertion_counter = nil)
331
339
  @expectations.verified?(assertion_counter)
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
- require "mocha/mini_test"
3
+ require "mocha/minitest"
4
4
  require "integration/shared_tests"
5
5
 
6
6
  class MiniTestTest < Mocha::TestCase
@@ -179,10 +179,9 @@ end
179
179
  def test_should_return_mock_for_stubbee
180
180
  mocha = Object.new
181
181
  stubbee = Object.new
182
- stubbee.define_instance_accessor(:mocha) { mocha }
183
- stubbee.mocha = nil
182
+ stubbee.define_instance_method(:mocha) { mocha }
184
183
  method = ClassMethod.new(stubbee, :method_name)
185
- assert_equal stubbee.mocha, method.mock
184
+ assert_equal mocha, method.mock
186
185
  end
187
186
 
188
187
  def test_should_not_match_if_other_object_has_a_different_class
@@ -334,6 +334,14 @@ class MockTest < Mocha::TestCase
334
334
  assert_match(/unexpected invocation/, e.message)
335
335
  end
336
336
 
337
+ unless PRE_RUBY_V19
338
+ def test_expectation_is_defined_on_mock
339
+ mock = build_mock
340
+ mock.expects(:method1)
341
+ assert defined? mock.method1
342
+ end
343
+ end
344
+
337
345
  private
338
346
 
339
347
  def build_mock
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.3.0
4
+ version: 1.4.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: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metaclass
@@ -179,6 +179,7 @@ files:
179
179
  - lib/mocha/logger.rb
180
180
  - lib/mocha/method_matcher.rb
181
181
  - lib/mocha/mini_test.rb
182
+ - lib/mocha/minitest.rb
182
183
  - lib/mocha/mock.rb
183
184
  - lib/mocha/mockery.rb
184
185
  - lib/mocha/module_method.rb
@@ -377,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
377
378
  version: '0'
378
379
  requirements: []
379
380
  rubyforge_project: mocha
380
- rubygems_version: 2.6.12
381
+ rubygems_version: 2.6.11
381
382
  signing_key:
382
383
  specification_version: 3
383
384
  summary: Mocking and stubbing library