Skip to content

Commit 5c0ecb0

Browse files
authored
Merge pull request #472 from ghiculescu/use-the-good-error
Raise the error that includes an error message
2 parents 1a0cf7a + 22b1747 commit 5c0ecb0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/sprockets/rails/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def precompiled?(path)
369369
end
370370

371371
def raise_unless_precompiled_asset(path)
372-
raise Helper::AssetNotPrecompiled.new(path) if @check_precompiled_asset && !precompiled?(path)
372+
raise Helper::AssetNotPrecompiledError.new(path) if @check_precompiled_asset && !precompiled?(path)
373373
end
374374
end
375375
end

test/test_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,12 +880,20 @@ def setup
880880
@bundle_js_name = '/assets/bundle.js'
881881
end
882882

883+
# both subclass and more specific error are supported due to
884+
# https://github.com/rails/sprockets-rails/pull/414/commits/760a805a9f56d3df0d4b83bd4a5a6476eb3aeb29
883885
def test_javascript_precompile
884886
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiled) do
885887
@view.javascript_include_tag("not_precompiled")
886888
end
887889
end
888890

891+
def test_javascript_precompile_thows_the_descriptive_error
892+
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiledError) do
893+
@view.javascript_include_tag("not_precompiled")
894+
end
895+
end
896+
889897
def test_stylesheet_precompile
890898
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiled) do
891899
@view.stylesheet_link_tag("not_precompiled")

0 commit comments

Comments
 (0)