diff options
Diffstat (limited to 'railties/test/generators/channel_generator_test.rb')
-rw-r--r-- | railties/test/generators/channel_generator_test.rb | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb index e3edde681f..e238197eba 100644 --- a/railties/test/generators/channel_generator_test.rb +++ b/railties/test/generators/channel_generator_test.rb @@ -1,12 +1,14 @@ -require 'generators/generators_test_helper' -require 'rails/generators/channel/channel_generator' +# frozen_string_literal: true + +require "generators/generators_test_helper" +require "rails/generators/channel/channel_generator" class ChannelGeneratorTest < Rails::Generators::TestCase include GeneratorsTestHelper tests Rails::Generators::ChannelGenerator def test_application_cable_skeleton_is_created - run_generator ['books'] + run_generator ["books"] assert_file "app/channels/application_cable/channel.rb" do |cable| assert_match(/module ApplicationCable\n class Channel < ActionCable::Channel::Base\n/, cable) @@ -18,19 +20,19 @@ class ChannelGeneratorTest < Rails::Generators::TestCase end def test_channel_is_created - run_generator ['chat'] + run_generator ["chat"] assert_file "app/channels/chat_channel.rb" do |channel| assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) end assert_file "app/assets/javascripts/channels/chat.js" do |channel| - assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel) + assert_match(/App\.chat = App\.cable\.subscriptions\.create\("ChatChannel/, channel) end end def test_channel_with_multiple_actions_is_created - run_generator ['chat', 'speak', 'mute'] + run_generator ["chat", "speak", "mute"] assert_file "app/channels/chat_channel.rb" do |channel| assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) @@ -39,14 +41,14 @@ class ChannelGeneratorTest < Rails::Generators::TestCase end assert_file "app/assets/javascripts/channels/chat.js" do |channel| - assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel) + assert_match(/App\.chat = App\.cable\.subscriptions\.create\("ChatChannel/, channel) assert_match(/,\n\n speak/, channel) assert_match(/,\n\n mute: function\(\) \{\n return this\.perform\('mute'\);\n \}\n\}\);/, channel) end end def test_channel_asset_is_not_created_when_skip_assets_is_passed - run_generator ['chat', '--skip-assets'] + run_generator ["chat", "--skip-assets"] assert_file "app/channels/chat_channel.rb" do |channel| assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) @@ -56,16 +58,16 @@ class ChannelGeneratorTest < Rails::Generators::TestCase end def test_cable_js_is_created_if_not_present_already - run_generator ['chat'] + run_generator ["chat"] FileUtils.rm("#{destination_root}/app/assets/javascripts/cable.js") - run_generator ['camp'] + run_generator ["camp"] assert_file "app/assets/javascripts/cable.js" end def test_channel_on_revoke - run_generator ['chat'] - run_generator ['chat'], behavior: :revoke + run_generator ["chat"] + run_generator ["chat"], behavior: :revoke assert_no_file "app/channels/chat_channel.rb" assert_no_file "app/assets/javascripts/channels/chat.js" |