-
-
Notifications
You must be signed in to change notification settings - Fork 272
Testing
Craig Wickesser edited this page Sep 11, 2013
·
5 revisions
Dear @tarcieri, please to be expanding this content. Hugs, @mperham.
For now, there's this.
I've found that attempting to stub a method on an actor causes my RSpec tests to hang. For example:
class Foo
include Celluloid
def enabled?
false
end
def do_work
if enabled?
do_stuff
else
do_other_stuff
end
end
end
describe Foo do
describe "#do_work" do
# this test hangs
it "do stuff when enabled" do
f = Foo.new
f.stub(:enabled?) { true }
f.should_receive(:do_stuff)
f.do_work
end
# approach that's working for me (instance_eval on the #wrapped_object)
it "do stuff when enabled" do
f = Foo.new
f.wrapped_object.instance_eval do
def enabled?
true
end
end
f.should_receive(:do_stuff)
f.do_work
end
end
end
Always feel free to:
- Visit the
#celluloid
channel on freenode. - Post a bug report or feature request.
- Ask questions on our mailing list.