celluloid: Stubbing actor internals doesn't work
require 'celluloid'
class A
include Celluloid
def b
c
end
def c
"Hello"
end
end
describe A do
it "should allow mocking" do
subject.should_receive(:c).twice.and_return "World"
subject.c.should == "World"
subject.b.should == "World"
end
end
In this instance, it can be seen that from outside of the A instance, calling the stubbed method works, but it does not internally. Removing the Celluloid include causes the test to pass.
Any ideas?
About this issue
- Original URL
- State: closed
- Created 13 years ago
- Comments: 23 (17 by maintainers)
Commits related to this issue
- Merge pull request #7 from grantr/subscribe add subscribe and unsubscribe to sub sockets — committed to celluloid/celluloid by tarcieri 12 years ago
- Merge pull request #7 from abstractive/e2_method_checking_proxy method checking proxies + alter exception type — committed to celluloid/celluloid by deleted user 9 years ago
- Fix missing expectation See also https://github.com/celluloid/celluloid/issues/7. — committed to potomak/karafka by potomak 8 years ago
- Fix missing expectation See also https://github.com/celluloid/celluloid/issues/7. — committed to potomak/karafka by potomak 8 years ago
- massive supervision refactor; closes #7, closes #1 ( through depreciation ) and nearly there with celluloid/celluloid#511 — committed to celluloid/celluloid by deleted user 9 years ago
@tarcieri: Correct. RSpec is stubbing the Celluloid::Actor object, and so calls that go via that hit the stub and not the delegate. When the delegate makes the method call, however, it knows nothing of the Actor, and thus the stub, and uses the implementation as it’s written. It’s a definite scope issue, I’m just not sure how to deal with it. It’s not as if we can have the delegate make any calls on self via the Actor (or can we?).
@dchelimsky: Mocha behaves the same as RSpec. The bug is most definitely in Celluloid.