Skip to content

Commit

Permalink
Raise the error that includes an error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiculescu committed Mar 18, 2021
1 parent 1a0cf7a commit e7c5e70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sprockets/rails/helper.rb
Expand Up @@ -369,7 +369,7 @@ def precompiled?(path)
end

def raise_unless_precompiled_asset(path)
raise Helper::AssetNotPrecompiled.new(path) if @check_precompiled_asset && !precompiled?(path)
raise Helper::AssetNotPrecompiledError.new(path) if @check_precompiled_asset && !precompiled?(path)
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_helper.rb
Expand Up @@ -880,12 +880,20 @@ def setup
@bundle_js_name = '/assets/bundle.js'
end

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

def test_javascript_precompile_thows_the_descriptive_error
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiledError) do
@view.javascript_include_tag("not_precompiled")
end
end

def test_stylesheet_precompile
assert_raises(Sprockets::Rails::Helper::AssetNotPrecompiled) do
@view.stylesheet_link_tag("not_precompiled")
Expand Down

0 comments on commit e7c5e70

Please sign in to comment.