1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/test/channel/stream_test.rb

26 lines
681 B
Ruby
Raw Normal View History

2015-07-12 11:07:31 -04:00
require 'test_helper'
require 'stubs/test_connection'
class ActionCable::Channel::StreamTest < ActiveSupport::TestCase
Room = Struct.new(:id)
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