aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/test
diff options
context:
space:
mode:
authorutilum <oz@utilum.com>2018-05-31 17:32:52 +0200
committerutilum <oz@utilum.com>2018-05-31 17:48:20 +0200
commita0ea528b612f9d8cdd14a5b76fdcf6719b7db56a (patch)
treece8a134e1e247d5648771ba9260b16721f2e473e /actioncable/test
parent84854d9d05c10b091a03767359c3c6ccf4450f26 (diff)
downloadrails-a0ea528b612f9d8cdd14a5b76fdcf6719b7db56a.tar.gz
rails-a0ea528b612f9d8cdd14a5b76fdcf6719b7db56a.tar.bz2
rails-a0ea528b612f9d8cdd14a5b76fdcf6719b7db56a.zip
Use Ruby instead of mocha
Diffstat (limited to 'actioncable/test')
-rw-r--r--actioncable/test/channel/stream_test.rb8
-rw-r--r--actioncable/test/connection/identifier_test.rb13
-rw-r--r--actioncable/test/stubs/test_adapter.rb4
3 files changed, 19 insertions, 6 deletions
diff --git a/actioncable/test/channel/stream_test.rb b/actioncable/test/channel/stream_test.rb
index dbb53fec1f..ed42f1acd4 100644
--- a/actioncable/test/channel/stream_test.rb
+++ b/actioncable/test/channel/stream_test.rb
@@ -96,11 +96,17 @@ module ActionCable::StreamTests
test "stream_for" do
run_in_eventmachine do
connection = TestConnection.new
- connection.pubsub.expects(:subscribe).with("action_cable:stream_tests:chat:Room#1-Campfire", kind_of(Proc), kind_of(Proc))
channel = ChatChannel.new connection, ""
channel.subscribe_to_channel
channel.stream_for Room.new(1)
+ wait_for_async
+
+ pubsub_call = channel.pubsub.class.class_variable_get "@@subscribe_called"
+
+ assert_equal "action_cable:stream_tests:chat:Room#1-Campfire", pubsub_call[:channel]
+ assert_instance_of Proc, pubsub_call[:callback]
+ assert_instance_of Proc, pubsub_call[:success_callback]
end
end
diff --git a/actioncable/test/connection/identifier_test.rb b/actioncable/test/connection/identifier_test.rb
index 204197c2a7..a7e23b4cd8 100644
--- a/actioncable/test/connection/identifier_test.rb
+++ b/actioncable/test/connection/identifier_test.rb
@@ -30,13 +30,16 @@ class ActionCable::Connection::IdentifierTest < ActionCable::TestCase
run_in_eventmachine do
server = TestServer.new
- server.pubsub.expects(:subscribe)
- .with("action_cable/User#lifo", kind_of(Proc))
- server.pubsub.expects(:unsubscribe)
- .with("action_cable/User#lifo", kind_of(Proc))
-
open_connection(server)
close_connection
+ wait_for_async
+
+ %w[subscribe unsubscribe].each do |method|
+ pubsub_call = server.pubsub.class.class_variable_get "@@#{method}_called"
+
+ assert_equal "action_cable/User#lifo", pubsub_call[:channel]
+ assert_instance_of Proc, pubsub_call[:callback]
+ end
end
end
diff --git a/actioncable/test/stubs/test_adapter.rb b/actioncable/test/stubs/test_adapter.rb
index c481046973..5f23a137ea 100644
--- a/actioncable/test/stubs/test_adapter.rb
+++ b/actioncable/test/stubs/test_adapter.rb
@@ -1,12 +1,16 @@
# frozen_string_literal: true
class SuccessAdapter < ActionCable::SubscriptionAdapter::Base
+ class << self; attr_accessor :subscribe_called, :unsubscribe_called end
+
def broadcast(channel, payload)
end
def subscribe(channel, callback, success_callback = nil)
+ @@subscribe_called = { channel: channel, callback: callback, success_callback: success_callback }
end
def unsubscribe(channel, callback)
+ @@unsubscribe_called = { channel: channel, callback: callback }
end
end