spec/unit/realtime/connection_spec.rb in ably-0.1.5 vs spec/unit/realtime/connection_spec.rb in ably-0.1.6
- old
+ new
@@ -1,25 +1,18 @@
require 'spec_helper'
-require "support/protocol_msgbus_helper"
+require 'support/protocol_msgbus_helper'
+require 'support/event_machine_helper'
describe Ably::Realtime::Connection do
- let(:client) { double(:client) }
- let(:klass) { Class.new(Ably::Realtime::Connection) do; end }
+ let(:client) { instance_double('Ably::Realtime::Client', logger: double('logger').as_null_object) }
- before do
- # Override self.new with a generic implementation of new as EventMachine::Connection
- # overrides self.new by default, and using EventMachine in unit tests is unnecessary
- klass.instance_eval do
- def self.new(*args)
- obj = self.allocate
- obj.orig_send :initialize, *args
- obj
- end
- end
+ subject do
+ Ably::Realtime::Connection.new(client)
end
- subject do
- klass.new(client)
+ before do
+ expect(EventMachine::Timer).to receive(:new)
+ expect(EventMachine).to receive(:next_tick)
end
describe 'callbacks' do
specify 'are supported for valid STATE events' do
state = nil