Skip to content

Commit 8e213f7

Browse files
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 4a23cb3, 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.
1 parent 859cab5 commit 8e213f7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

actioncable/test/javascript_package_test.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44

55
class JavascriptPackageTest < ActiveSupport::TestCase
66
def test_compiled_code_is_in_sync_with_source_code
7-
compiled_file = File.expand_path("../app/assets/javascripts/action_cable.js", __dir__)
7+
compiled_files = %w[
8+
app/assets/javascripts/actioncable.js
9+
app/assets/javascripts/actioncable.esm.js
10+
app/assets/javascripts/action_cable.js
11+
].map do |file|
12+
Pathname(file).expand_path("#{__dir__}/..")
13+
end
814

9-
assert_no_changes -> { File.read(compiled_file) } do
10-
system "yarn build"
15+
assert_no_changes -> { compiled_files.map(&:read) } do
16+
system "yarn build", exception: true
1117
end
1218
end
1319
end

0 commit comments

Comments
 (0)