Sha256: 7a0315fd377cf6be31b8d705ac0fd61ec1d958fb466120a00df0c33e95dfa0d5
Contents?: true
Size: 735 Bytes
Versions: 5
Compression:
Stored size: 735 Bytes
Contents
module FayeSupport class FakeFaye def on(type, &block) @events ||= {} @events[type] ||= [] @events[type] << block end def send_event(type, data) Array(Hash(@events)[type]).each do |block| block.call(data) end end def message(message, extra_args = {}) send_event( :message, OpenStruct.new( data: { "type" => "message", "text" => message }.merge(extra_args).to_json ) ) end end def self.included(base) base.instance_eval do let(:faye) { FakeFaye.new } before do allow(Faye::WebSocket::Client).to receive(:new).and_return faye end around(&:run) end end end
Version data entries
5 entries across 5 versions & 1 rubygems