spec/slack/real_time/client_spec.rb in slack-ruby-client-2.1.0 vs spec/slack/real_time/client_spec.rb in slack-ruby-client-2.2.0
- old
+ new
@@ -157,21 +157,39 @@
expect(client.store.team.name).to eq 'New Team Name Inc.'
end
end
describe '#run_handlers' do
- context 'when store has no event hooks' do
+ before do
+ @events = client.store.class.events.dup
+ @async_handlers = client.async_handlers.dup
+ client.store.class.events.clear
+ end
+
+ after do
+ client.store.class.events.merge!(@events)
+ client.async_handlers = @async_handlers
+ end
+
+ context 'when config#async_handlers is :all' do
before do
- @events = client.store.class.events.dup
- client.store.class.events.clear
+ client.async_handlers = :all
end
- after do
- client.store.class.events.merge!(@events)
+ it 'runs tasks async' do
+ expect(socket).to receive(:run_async)
+ client.send(:run_handlers, 'example', {})
end
+ end
- it 'returns empty array of handlers' do
- expect(client.send(:run_handlers, 'example', {})).to be_empty
+ context 'when config#async_handlers is :none' do
+ before do
+ client.async_handlers = :none
+ end
+
+ it 'does not run tasks async' do
+ expect(socket).not_to receive(:run_async)
+ client.send(:run_handlers, 'example', {})
end
end
end
end