From 8e213f72dd137086a783ea64d4ca5e036713c490 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Sun, 5 Nov 2023 11:58:03 -0600 Subject: [PATCH] Update JavascriptPackageTest for Action Cable Prior to this commit, if `app/javascript/action_cable/index.js` contained a syntax error, `JavascriptPackageTest` would still pass because `system "yarn build"` would simply return `false` and the compiled output would not change. This commit adds `exception: true` to the `system` call so that an error will be raised if `yarn build` fails. Also, since 4a23cb3415eac03d76623112576559a722d1f23d, Active Storage compiles additional `app/assets/javascripts/actioncable.js` and `app/assets/javascripts/actioncable.esm.js` files (with `app/assets/javascripts/action_cable.js` being deprecated). This commit adds assertions for those files as well. --- actioncable/test/javascript_package_test.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/actioncable/test/javascript_package_test.rb b/actioncable/test/javascript_package_test.rb index 421eab2d60..948f98e686 100644 --- a/actioncable/test/javascript_package_test.rb +++ b/actioncable/test/javascript_package_test.rb @@ -4,10 +4,16 @@ class JavascriptPackageTest < ActiveSupport::TestCase def test_compiled_code_is_in_sync_with_source_code - compiled_file = File.expand_path("../app/assets/javascripts/action_cable.js", __dir__) + compiled_files = %w[ + app/assets/javascripts/actioncable.js + app/assets/javascripts/actioncable.esm.js + app/assets/javascripts/action_cable.js + ].map do |file| + Pathname(file).expand_path("#{__dir__}/..") + end - assert_no_changes -> { File.read(compiled_file) } do - system "yarn build" + assert_no_changes -> { compiled_files.map(&:read) } do + system "yarn build", exception: true end end end