aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2018-08-23 09:34:27 -0400
committerGitHub <noreply@github.com>2018-08-23 09:34:27 -0400
commita0b57bbb21ce81071220bd8c6cfd8cdda342c6c6 (patch)
tree03a805bdda4b782398ad9402cbe1630202ee4443
parent4b4207af2fbec0f6e0171ca637e71b9801cbc65c (diff)
parent86e7de7968b91bd4256bb07ffbe689b385180910 (diff)
downloadrails-a0b57bbb21ce81071220bd8c6cfd8cdda342c6c6.tar.gz
rails-a0b57bbb21ce81071220bd8c6cfd8cdda342c6c6.tar.bz2
rails-a0b57bbb21ce81071220bd8c6cfd8cdda342c6c6.zip
Merge pull request #33703 from bogdanvlviv/follow-up-33659
Follow up #33659
-rw-r--r--actioncable/lib/action_cable/subscription_adapter/test.rb2
-rw-r--r--actioncable/lib/action_cable/test_helper.rb7
-rw-r--r--actioncable/test/test_helper.rb2
-rw-r--r--actioncable/test/test_helper_test.rb10
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/cable.yml.tt2
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