Created
June 12, 2014 10:42
-
-
Save tombh/ffa163e8c05beb3c8317 to your computer and use it in GitHub Desktop.
Rspec exception getting caught by async method
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
require 'celluloid' | |
# It wasn't until I commented out this line that I realised what was actually going on below | |
# Celluloid.logger = nil | |
class Foo | |
include Celluloid | |
def do | |
bar | |
end | |
def bar; end | |
end | |
describe Foo do | |
let(:instance){Foo.new} | |
it 'should detect a message being sent' do | |
expect(instance.wrapped_object).to receive(:bar) | |
instance.async.do | |
sleep 0.1 | |
end | |
it 'THIS TEST SHOULD FAIL' do | |
expect(instance.wrapped_object).to_not receive(:bar) | |
instance.async.do | |
sleep 0.1 | |
end | |
end |
While this may very well be a bug, the test is inherently racy
Sorry, I never got a notification about your response. But thanks. I seem to remember I fixed it by taking a completely different approach. I do still sometimes find myself using sleeps in Celluloid specs, which can't be good. I just need to be more imaginative I think.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output of above spec: