mocha 1.2.0 → 1.2.1

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: db34295002c13283fa7653ae3a1474a77bf081f2
4
- data.tar.gz: ce7b148d39f32c3e9d0c527d679d1295b6440b0a
3
+ metadata.gz: 41ba040450c12b37d2cce4a23948f3944b97a003
4
+ data.tar.gz: 386b73723224bcaf481cc15324ba0dbe5534e423
5
5
  SHA512:
6
- metadata.gz: cfee63cd238bb06188c8c73bcd864c4b6c0e6d89e0433f85eb65ade2e1607c8557e370e448a6d98c5609a22db07d1f07240fb13c606323ae86694362b7342f0f
7
- data.tar.gz: fb2ae63bf63e64df43d60d7ec48548b6410f8d4c594039b6abdf50d8f3fabb6c3c91fabd99920f97e1ff76e429135c0aca02bae217213cab313a65b47e784ae4
6
+ metadata.gz: 2c5537469c485a8fb71dc4c41a16355b5e9401eab0b157554f7f4c374b4b468b0a30ebd17fcd8b8c76b8cf4babdf2d3118e4147b5a65ca88d5c9a1ab7ded31c9
7
+ data.tar.gz: d0f420d06bf65eb02c49fbaa0077cb6f2c2d6f7f1ab41d5e622aec3ee761a2f0824ac2bdad2d602cfc83c508a11e3121e6166cbf61140801cbfd6ad3a7a4fc11
data/README.md CHANGED
@@ -109,6 +109,7 @@ require 'mocha/mini_test'
109
109
 
110
110
  #### Known Issues
111
111
 
112
+ * In Mocha v1.2.0 there is a scenario where stubbing a class method originally defined in a module hangs the Ruby interpreter due to [a bug in Ruby v2.3.1](https://bugs.ruby-lang.org/issues/12832). See #272. This was fixed in Mocha v1.2.1.
112
113
  * Stubbing an aliased class method, where the original method is defined in a module that's used to `extend` the class doesn't work in Ruby 1.8.x. See stub_method_defined_on_module_and_aliased_test.rb for an example of this behaviour.
113
114
  * 0.13.x versions cause a harmless, but annoying, deprecation warning when used with Rails 3.2.0-3.2.12, 3.1.0-3.1.10 & 3.0.0-3.0.19.
114
115
  * 0.11.x versions don't work with Rails 3.2.13 (`TypeError: superclass mismatch for class ExpectationError`). See #115.
data/RELEASE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release Notes
2
2
 
3
+ ## 1.2.1
4
+
5
+ * Fixed #272. Workaround Ruby bug 12832 which caused interpreter to hang. See https://bugs.ruby-lang.org/issues/12832. Thanks to @chrisroos & @petems (6f1c8b9b, #273).
6
+
3
7
  ## 1.2.0
4
8
 
5
9
  * Always use prepended module to stub class & instance methods for Ruby v2+ - thanks to @grosser & @chrisroos (43d56671, #244)
@@ -40,11 +40,11 @@ module Mocha
40
40
  def hide_original_method
41
41
  if @original_visibility = method_visibility(method)
42
42
  begin
43
- @original_method = stubbee._method(method)
44
43
  if RUBY_V2_PLUS
45
44
  @definition_target = PrependedModule.new
46
45
  stubbee.__metaclass__.__send__ :prepend, @definition_target
47
46
  else
47
+ @original_method = stubbee._method(method)
48
48
  if @original_method && @original_method.owner == stubbee.__metaclass__
49
49
  stubbee.__metaclass__.send(:remove_method, method)
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module Mocha
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -0,0 +1,52 @@
1
+ require File.expand_path('../acceptance_test_helper', __FILE__)
2
+ require 'mocha/setup'
3
+
4
+ class Issue272Test < Mocha::TestCase
5
+
6
+ include AcceptanceTest
7
+
8
+ def setup
9
+ setup_acceptance_test
10
+ end
11
+
12
+ def teardown
13
+ teardown_acceptance_test
14
+ end
15
+
16
+ module Mod
17
+ private
18
+
19
+ def foo
20
+ 'original-foo'
21
+ end
22
+
23
+ def bar
24
+ 'original-bar'
25
+ end
26
+ end
27
+
28
+ class Klass
29
+ extend Mod
30
+
31
+ class << self
32
+ public :foo
33
+ public :bar
34
+ end
35
+ end
36
+
37
+ def test_private_methods_in_module_used_to_extend_class_and_made_public
38
+ test_result = run_as_test do
39
+ Klass.stubs(:foo).returns('stubbed-foo')
40
+ # hangs in next line executing:
41
+ # `@original_method = stubbee._method(method)`
42
+ # in Mocha::ClassMethod#hide_original_method
43
+ # but only in Ruby v2.3, not v2.2
44
+ Klass.stubs(:bar).returns('stubbed-bar')
45
+ assert_equal 'stubbed-foo', Klass.foo
46
+ assert_equal 'stubbed-bar', Klass.bar
47
+ end
48
+ assert_passed(test_result)
49
+ assert_equal 'original-foo', Klass.foo
50
+ assert_equal 'original-bar', Klass.bar
51
+ end
52
+ 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: 1.2.0
4
+ version: 1.2.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: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metaclass
@@ -236,6 +236,7 @@ files:
236
236
  - test/acceptance/expectations_on_multiple_methods_test.rb
237
237
  - test/acceptance/expected_invocation_count_test.rb
238
238
  - test/acceptance/failure_messages_test.rb
239
+ - test/acceptance/issue_272_test.rb
239
240
  - test/acceptance/issue_65_test.rb
240
241
  - test/acceptance/issue_70_test.rb
241
242
  - test/acceptance/mocha_example_test.rb