rspec-mocks 3.3.1 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +8 -0
- data/lib/rspec/mocks/mutex.rb +73 -0
- data/lib/rspec/mocks/reentrant_mutex.rb +53 -0
- data/lib/rspec/mocks/space.rb +3 -11
- data/lib/rspec/mocks/version.rb +1 -1
- metadata +19 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 159a6b84817d3fe5b931c2fa0158a88ac84ab6d5
|
4
|
+
data.tar.gz: c9b42659f94d5814fc4aeb107954eb15763a9e93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0f3c1c4ec0ebd3efbbf608c3c749f1af4354aa78264c0738241a8585d4c8b170508ead0da894f2808fb1c43d692b1d7a910744b95ce20f4c3f1c2f7e8ef2d4e
|
7
|
+
data.tar.gz: 52b08792990f741a014390e5886fe49226b7c22ca90db1e01e0b26728571020702ce37d6b635a3df87635275b4c05606dfbd475b68120c7664fade2a86a20d86
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 3.3.2 / 2015-07-15
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.3.1...v3.3.2)
|
3
|
+
|
4
|
+
Bug Fixes:
|
5
|
+
|
6
|
+
* Prevent thread deadlock errors during proxy creation (e.g. when using
|
7
|
+
`before_verifying_doubles` callbacks). (Jon Rowe, #980, #979)
|
8
|
+
|
1
9
|
### 3.3.1 / 2015-06-19
|
2
10
|
[Full Changelog](http://github.com/rspec/rspec-mocks/compare/v3.3.0...v3.3.1)
|
3
11
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Mocks
|
3
|
+
# On 1.8.7, it's in the stdlib.
|
4
|
+
# We don't want to load the stdlib, b/c this is a test tool, and can affect
|
5
|
+
# the test environment, causing tests to pass where they should fail.
|
6
|
+
#
|
7
|
+
# So we're transcribing/modifying it from
|
8
|
+
# https://github.com/ruby/ruby/blob/v1_8_7_374/lib/thread.rb#L56
|
9
|
+
# Some methods we don't need are deleted. Anything I don't
|
10
|
+
# understand (there's quite a bit, actually) is left in.
|
11
|
+
#
|
12
|
+
# Some formating changes are made to appease the robot overlord:
|
13
|
+
# https://travis-ci.org/rspec/rspec-core/jobs/54410874
|
14
|
+
# @private
|
15
|
+
class Mutex
|
16
|
+
def initialize
|
17
|
+
@waiting = []
|
18
|
+
@locked = false
|
19
|
+
@waiting.taint
|
20
|
+
taint
|
21
|
+
end
|
22
|
+
|
23
|
+
# @private
|
24
|
+
def lock
|
25
|
+
while Thread.critical = true && @locked
|
26
|
+
@waiting.push Thread.current
|
27
|
+
Thread.stop
|
28
|
+
end
|
29
|
+
@locked = true
|
30
|
+
Thread.critical = false
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
# @private
|
35
|
+
def unlock
|
36
|
+
return unless @locked
|
37
|
+
Thread.critical = true
|
38
|
+
@locked = false
|
39
|
+
wakeup_and_run_waiting_thread
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
# @private
|
44
|
+
def synchronize
|
45
|
+
lock
|
46
|
+
begin
|
47
|
+
yield
|
48
|
+
ensure
|
49
|
+
unlock
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def wakeup_and_run_waiting_thread
|
56
|
+
begin
|
57
|
+
t = @waiting.shift
|
58
|
+
t.wakeup if t
|
59
|
+
rescue ThreadError
|
60
|
+
retry
|
61
|
+
end
|
62
|
+
Thread.critical = false
|
63
|
+
begin
|
64
|
+
t.run if t
|
65
|
+
rescue ThreadError
|
66
|
+
:noop
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Avoid warnings for library wide checks spec
|
71
|
+
end unless defined?(::RSpec::Mocks::Mutex) || defined?(::Mutex)
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Mocks
|
3
|
+
# Allows a thread to lock out other threads from a critical section of code,
|
4
|
+
# while allowing the thread with the lock to reenter that section.
|
5
|
+
#
|
6
|
+
# Based on Monitor as of 2.2 -
|
7
|
+
# https://github.com/ruby/ruby/blob/eb7ddaa3a47bf48045d26c72eb0f263a53524ebc/lib/monitor.rb#L9
|
8
|
+
#
|
9
|
+
# Depends on Mutex, but Mutex is only available as part of core since 1.9.1:
|
10
|
+
# exists - http://ruby-doc.org/core-1.9.1/Mutex.html
|
11
|
+
# dne - http://ruby-doc.org/core-1.9.0/Mutex.html
|
12
|
+
#
|
13
|
+
# @private
|
14
|
+
class ReentrantMutex
|
15
|
+
def initialize
|
16
|
+
@owner = nil
|
17
|
+
@count = 0
|
18
|
+
@mutex = Mutex.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def synchronize
|
22
|
+
enter
|
23
|
+
yield
|
24
|
+
ensure
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def enter
|
31
|
+
@mutex.lock if @owner != Thread.current
|
32
|
+
@owner = Thread.current
|
33
|
+
@count += 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def exit
|
37
|
+
@count -= 1
|
38
|
+
return unless @count == 0
|
39
|
+
@owner = nil
|
40
|
+
@mutex.unlock
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if defined? ::Mutex
|
45
|
+
# On 1.9 and up, this is in core, so we just use the real one
|
46
|
+
Mutex = ::Mutex
|
47
|
+
else # For 1.8.7
|
48
|
+
# :nocov:
|
49
|
+
RSpec::Support.require_rspec_mocks "mutex"
|
50
|
+
# :nocov:
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/rspec/mocks/space.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
RSpec::Support.require_rspec_mocks 'reentrant_mutex'
|
2
|
+
|
1
3
|
module RSpec
|
2
4
|
module Mocks
|
3
5
|
# @private
|
@@ -142,18 +144,8 @@ module RSpec
|
|
142
144
|
|
143
145
|
private
|
144
146
|
|
145
|
-
# We don't want to depend on the stdlib ourselves, but if the user is
|
146
|
-
# using threads then a Mutex will be available to us. If not, we don't
|
147
|
-
# need to synchronize anyway.
|
148
147
|
def new_mutex
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
# @private
|
153
|
-
module FakeMutex
|
154
|
-
def self.synchronize
|
155
|
-
yield
|
156
|
-
end
|
148
|
+
Mocks::ReentrantMutex.new
|
157
149
|
end
|
158
150
|
|
159
151
|
def proxy_not_found_for(id, object)
|
data/lib/rspec/mocks/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Baker
|
@@ -45,7 +45,7 @@ cert_chain:
|
|
45
45
|
ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
|
46
46
|
F3MdtaDehhjC
|
47
47
|
-----END CERTIFICATE-----
|
48
|
-
date: 2015-
|
48
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
49
49
|
dependencies:
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: rspec-support
|
@@ -137,6 +137,20 @@ dependencies:
|
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '5.2'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: thread_order
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.1.0
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 1.1.0
|
140
154
|
description: RSpec's 'test double' framework, with support for stubbing and mocking
|
141
155
|
email: rspec@googlegroups.com
|
142
156
|
executables: []
|
@@ -176,9 +190,11 @@ files:
|
|
176
190
|
- lib/rspec/mocks/method_double.rb
|
177
191
|
- lib/rspec/mocks/method_reference.rb
|
178
192
|
- lib/rspec/mocks/mutate_const.rb
|
193
|
+
- lib/rspec/mocks/mutex.rb
|
179
194
|
- lib/rspec/mocks/object_reference.rb
|
180
195
|
- lib/rspec/mocks/order_group.rb
|
181
196
|
- lib/rspec/mocks/proxy.rb
|
197
|
+
- lib/rspec/mocks/reentrant_mutex.rb
|
182
198
|
- lib/rspec/mocks/space.rb
|
183
199
|
- lib/rspec/mocks/standalone.rb
|
184
200
|
- lib/rspec/mocks/syntax.rb
|
@@ -212,6 +228,6 @@ rubyforge_project:
|
|
212
228
|
rubygems_version: 2.2.2
|
213
229
|
signing_key:
|
214
230
|
specification_version: 4
|
215
|
-
summary: rspec-mocks-3.3.
|
231
|
+
summary: rspec-mocks-3.3.2
|
216
232
|
test_files: []
|
217
233
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|