Skip to content

Commit

Permalink
Merge pull request #472 from ghiculescu/use-the-good-error
Browse files Browse the repository at this point in the history
Raise the error that includes an error message
  • Loading branch information
rafaelfranca authored Jun 14, 2021
2 parents 1a0cf7a + 22b1747 commit 5c0ecb0
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 5c0ecb0

Please sign in to comment.