-
Notifications
You must be signed in to change notification settings - Fork 1
Testing
bnorton edited this page Mar 26, 2013
·
3 revisions
- Use the Custom rspec matcher for asynchronous expectations on class instances
:should_receive_async(Coming soon) - Use a direct
:should_receiveon the_asyncpost-fixed method you want to call.
describe User do
describe '#save' do
describe 'on create' do
let(:user) { FactoryGirl.build(:user) }
# a model instance
it 'should update the social profile' do
user.should_receive_async(:update_social_profile) # Custom rspec matcher (1.)
user.save!
end
end
describe 'when the user changes' do
before do
user.last_event = event
end
# Dedicated Worker Class
it 'should update social data' do
SocialDataUpdater.should_receive(:perform_async).with(user.id) # direct message expectation (2.)
user.save!
end
end
end
end