rspec-mocks 2.14.2 → 2.14.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +8 -0
- data/lib/rspec/mocks/instance_method_stasher.rb +6 -0
- data/lib/rspec/mocks/version.rb +1 -1
- data/spec/rspec/mocks/stub_spec.rb +37 -0
- metadata +5 -5
data/Changelog.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 2.14.3 / 2013-08-08
|
2
|
+
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.2...v2.14.3)
|
3
|
+
|
4
|
+
Bug Fixes:
|
5
|
+
|
6
|
+
* Fix stubbing some instance methods for classes whose hierarchy includes
|
7
|
+
a prepended Module (Bradley Schaefer)
|
8
|
+
|
1
9
|
### 2.14.2 / 2013-07-30
|
2
10
|
[full changelog](http://github.com/rspec/rspec-mocks/compare/v2.14.1...v2.14.2)
|
3
11
|
|
@@ -38,6 +38,12 @@ module RSpec
|
|
38
38
|
# @private
|
39
39
|
def method_owned_by_klass?
|
40
40
|
owner = @klass.instance_method(@method).owner
|
41
|
+
|
42
|
+
# On Ruby 2.0.0+ the owner of a method on a class which has been
|
43
|
+
# `prepend`ed may actually be an instance, e.g.
|
44
|
+
# `#<MyClass:0x007fbb94e3cd10>`, rather than the expected `MyClass`.
|
45
|
+
owner = owner.class unless owner.is_a? Class
|
46
|
+
|
41
47
|
# On 1.8 (and some 1.9s -- e.g. rubinius) aliased methods
|
42
48
|
# can report the wrong owner. Example:
|
43
49
|
# class MyClass
|
data/lib/rspec/mocks/version.rb
CHANGED
@@ -177,6 +177,43 @@ module RSpec
|
|
177
177
|
|
178
178
|
expect(mod.hello).to eq(:hello)
|
179
179
|
end
|
180
|
+
|
181
|
+
if RUBY_VERSION >= '2.0.0'
|
182
|
+
context "with a prepended module (ruby 2.0.0+)" do
|
183
|
+
before do
|
184
|
+
mod = Module.new do
|
185
|
+
def existing_instance_method
|
186
|
+
"#{super}_prepended".to_sym
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
@prepended_class = Class.new(@class) do
|
191
|
+
prepend mod
|
192
|
+
|
193
|
+
def non_prepended_method
|
194
|
+
:not_prepended
|
195
|
+
end
|
196
|
+
end
|
197
|
+
@prepended_instance = @prepended_class.new
|
198
|
+
end
|
199
|
+
|
200
|
+
it "restores prepended instance methods" do
|
201
|
+
allow(@prepended_instance).to receive(:existing_instance_method) { :stubbed }
|
202
|
+
expect(@prepended_instance.existing_instance_method).to eq :stubbed
|
203
|
+
|
204
|
+
reset @prepended_instance
|
205
|
+
expect(@prepended_instance.existing_instance_method).to eq :original_value_prepended
|
206
|
+
end
|
207
|
+
|
208
|
+
it "restores non-prepended instance methods" do
|
209
|
+
allow(@prepended_instance).to receive(:non_prepended_method) { :stubbed }
|
210
|
+
expect(@prepended_instance.non_prepended_method).to eq :stubbed
|
211
|
+
|
212
|
+
reset @prepended_instance
|
213
|
+
expect(@prepended_instance.non_prepended_method).to eq :not_prepended
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
180
217
|
end
|
181
218
|
|
182
219
|
it "returns values in order to consecutive calls" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rspec-mocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.14.
|
5
|
+
version: 2.14.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steven Baker
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: -4603029701728341322
|
218
218
|
none: false
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
requirements:
|
@@ -223,14 +223,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
segments:
|
225
225
|
- 0
|
226
|
-
hash:
|
226
|
+
hash: -4603029701728341322
|
227
227
|
none: false
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project: rspec
|
230
230
|
rubygems_version: 1.8.24
|
231
231
|
signing_key:
|
232
232
|
specification_version: 3
|
233
|
-
summary: rspec-mocks-2.14.
|
233
|
+
summary: rspec-mocks-2.14.3
|
234
234
|
test_files:
|
235
235
|
- features/README.md
|
236
236
|
- features/Scope.md
|