diff options
-rw-r--r-- | actioncable/lib/action_cable/subscription_adapter/test.rb | 2 | ||||
-rw-r--r-- | actioncable/lib/action_cable/test_helper.rb | 7 | ||||
-rw-r--r-- | actioncable/test/test_helper.rb | 2 | ||||
-rw-r--r-- | actioncable/test/test_helper_test.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt | 2 |
5 files changed, 17 insertions, 6 deletions
diff --git a/actioncable/lib/action_cable/subscription_adapter/test.rb b/actioncable/lib/action_cable/subscription_adapter/test.rb index 52226a7c71..ce604cc88e 100644 --- a/actioncable/lib/action_cable/subscription_adapter/test.rb +++ b/actioncable/lib/action_cable/subscription_adapter/test.rb @@ -9,7 +9,7 @@ module ActionCable # The test adapter should be used only in testing. Along with # <tt>ActionCable::TestHelper</tt> it makes a great tool to test your Rails application. # - # To use the test adapter set adapter value to +test+ in your +cable.yml+. + # To use the test adapter set +adapter+ value to +test+ in your +config/cable.yml+ file. # # NOTE: Test adapter extends the <tt>ActionCable::SubscriptionsAdapter::Async</tt> adapter, # so it could be used in system tests too. diff --git a/actioncable/lib/action_cable/test_helper.rb b/actioncable/lib/action_cable/test_helper.rb index dbd5ec3b16..7bc877663c 100644 --- a/actioncable/lib/action_cable/test_helper.rb +++ b/actioncable/lib/action_cable/test_helper.rb @@ -47,11 +47,12 @@ module ActionCable original_count = broadcasts_size(stream) yield new_count = broadcasts_size(stream) - assert_equal number, new_count - original_count, "#{number} broadcasts to #{stream} expected, but #{new_count - original_count} were sent" + actual_count = new_count - original_count else actual_count = broadcasts_size(stream) - assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent" end + + assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent" end # Asserts that no messages have been sent to the stream. @@ -125,7 +126,7 @@ module ActionCable delegate :broadcasts, :clear_messages, to: :pubsub_adapter private - def broadcasts_size(channel) # :nodoc: + def broadcasts_size(channel) broadcasts(channel).size end end diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index f5b9ebf517..c924f1e475 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -17,7 +17,7 @@ Dir[File.expand_path("stubs/*.rb", __dir__)].each { |file| require file } # Set test adapter and logger ActionCable.server.config.cable = { "adapter" => "test" } -ActionCable.server.config.logger = Logger.new(StringIO.new).tap { |l| l.level = Logger::UNKNOWN } +ActionCable.server.config.logger = Logger.new(nil) class ActionCable::TestCase < ActiveSupport::TestCase include ActiveSupport::Testing::MethodCallAssertions diff --git a/actioncable/test/test_helper_test.rb b/actioncable/test/test_helper_test.rb index f82adb9c8f..90e3dbf01f 100644 --- a/actioncable/test/test_helper_test.rb +++ b/actioncable/test/test_helper_test.rb @@ -62,6 +62,16 @@ class TransmissionsTest < ActionCable::TestCase assert_match(/1 .* but 2/, error.message) end + + def test_assert_no_broadcasts_failure + error = assert_raises Minitest::Assertion do + assert_no_broadcasts "test" do + ActionCable.server.broadcast "test", "hello" + end + end + + assert_match(/0 .* but 1/, error.message) + end end class TransmitedDataTest < ActionCable::TestCase diff --git a/railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt b/railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt index 8e53156c71..f69dc91b92 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt @@ -2,7 +2,7 @@ development: adapter: async test: - adapter: async + adapter: test production: adapter: redis |