aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test/stubs
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-03-02 11:20:19 +1030
committerMatthew Draper <matthew@trebex.net>2016-03-02 12:17:15 +1030
commita373be9da45d4bee684ea03420212780ec1ef4b1 (patch)
tree3798c6117d8944189c84bd5363d49dbf935ea407 /actioncable/test/stubs
parent541e4abb4b3710a384aefac83cafd0ab878c60bf (diff)
downloadrails-a373be9da45d4bee684ea03420212780ec1ef4b1.tar.gz
rails-a373be9da45d4bee684ea03420212780ec1ef4b1.tar.bz2
rails-a373be9da45d4bee684ea03420212780ec1ef4b1.zip
Support faye-websocket + EventMachine as an option
Diffstat (limited to 'actioncable/test/stubs')
-rw-r--r--actioncable/test/stubs/test_connection.rb5
-rw-r--r--actioncable/test/stubs/test_server.rb14
2 files changed, 15 insertions, 4 deletions
diff --git a/actioncable/test/stubs/test_connection.rb b/actioncable/test/stubs/test_connection.rb
index da98201900..8ba284fdc6 100644
--- a/actioncable/test/stubs/test_connection.rb
+++ b/actioncable/test/stubs/test_connection.rb
@@ -1,18 +1,19 @@
require 'stubs/user'
class TestConnection
- attr_reader :identifiers, :logger, :current_user, :transmissions
+ attr_reader :identifiers, :logger, :current_user, :server, :transmissions
def initialize(user = User.new("lifo"))
@identifiers = [ :current_user ]
@current_user = user
@logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
+ @server = TestServer.new
@transmissions = []
end
def pubsub
- SuccessAdapter.new(TestServer.new)
+ SuccessAdapter.new(server)
end
def transmit(data)
diff --git a/actioncable/test/stubs/test_server.rb b/actioncable/test/stubs/test_server.rb
index 5916cf1e83..9e860825f3 100644
--- a/actioncable/test/stubs/test_server.rb
+++ b/actioncable/test/stubs/test_server.rb
@@ -8,14 +8,24 @@ class TestServer
def initialize
@logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
@config = OpenStruct.new(log_tags: [], subscription_adapter: SuccessAdapter)
+ @config.use_faye = ENV['FAYE'].present?
+ @config.client_socket_class = if @config.use_faye
+ ActionCable::Connection::FayeClientSocket
+ else
+ ActionCable::Connection::ClientSocket
+ end
end
def pubsub
@config.subscription_adapter.new(self)
end
- def stream_event_loop
- @stream_event_loop ||= ActionCable::Connection::StreamEventLoop.new
+ def event_loop
+ @event_loop ||= if @config.use_faye
+ ActionCable::Connection::FayeEventLoop.new
+ else
+ ActionCable::Connection::StreamEventLoop.new
+ end
end
def worker_pool