-
-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unstubing existing instances of any instance
* access proxies for any instance of klass * remove stubs from "running" instances * pass recorder into chains to register stubs * reduce lookup cost of proxies by klass * record stubs used * remove just the stubs recorded by any instance * switch from for..in to each * allow unstubing of instances that are a sub class * refactor lookup for subclass * Improve doc string. * "local instance" didn't really give me the right * sense for what this was testing. * Improve space spec. - The old spec only checked the number of proxies returned, and didn't actually check that it returned the right ones. - The old spec only tested who were instances of the given class, and did not check instances of subclasses.
- Loading branch information
1 parent
fda665f
commit 84ae8d1
Showing
11 changed files
with
101 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
module RSpec::Mocks | ||
describe Space do | ||
|
||
describe "#proxies_of(klass)" do | ||
let(:space) { Space.new } | ||
|
||
it 'returns proxies' do | ||
space.proxy_for("") | ||
expect(space.proxies_of(String).map(&:class)).to eq([Proxy]) | ||
end | ||
|
||
it 'returns only the proxies whose object is an instance of the given class' do | ||
grandparent_class = Class.new | ||
parent_class = Class.new(grandparent_class) | ||
child_class = Class.new(parent_class) | ||
|
||
grandparent = grandparent_class.new | ||
parent = parent_class.new | ||
child = child_class.new | ||
|
||
grandparent_proxy = space.proxy_for(grandparent) | ||
parent_proxy = space.proxy_for(parent) | ||
child_proxy = space.proxy_for(child) | ||
|
||
expect(space.proxies_of(parent_class)).to match_array([parent_proxy, child_proxy]) | ||
end | ||
end | ||
|
||
end | ||
end |