rails--rails/test/channel/stream_test.rb

25 lines
676 B
Ruby
Raw Normal View History

2015-07-12 15:07:31 +00:00
require 'test_helper'
require 'stubs/test_connection'
2015-07-13 15:43:52 +00:00
require 'stubs/room'
2015-07-12 15:07:31 +00:00
class ActionCable::Channel::StreamTest < ActiveSupport::TestCase
class ChatChannel < ActionCable::Channel::Base
def subscribed
@room = Room.new params[:id]
stream_from "test_room_#{@room.id}"
end
end
setup do
@connection = TestConnection.new
end
test "streaming start and stop" do
@connection.expects(:pubsub).returns mock().tap { |m| m.expects(:subscribe) }
channel = ChatChannel.new @connection, "{id: 1}", { id: 1 }
@connection.expects(:pubsub).returns mock().tap { |m| m.expects(:unsubscribe_proc) }
channel.unsubscribe_from_channel
end
end