Skip to content

Instantly share code, notes, and snippets.

@tombh
Created June 12, 2014 10:42
Show Gist options
  • Save tombh/ffa163e8c05beb3c8317 to your computer and use it in GitHub Desktop.
Save tombh/ffa163e8c05beb3c8317 to your computer and use it in GitHub Desktop.
Rspec exception getting caught by async method
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
@tombh
Copy link
Author

tombh commented Jul 12, 2014

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