Skip to content

Commit

Permalink
Appends load paths to error message with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Holger Frohloff authored and schneems committed Jun 22, 2016
1 parent 3543d11 commit a0e44ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/sprockets/resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def resolve!(path, **kargs)
end

message << " with type '#{kargs[:accept]}'" if kargs[:accept]
message << " with type '#{kargs[:accept]}'" if kargs[:accept]
message << "\nChecked in these paths: \n #{ kargs[:paths].join("\n ") }"

raise FileNotFound, message
end
Expand Down
12 changes: 12 additions & 0 deletions test/test_resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ def setup
resolve('manifest.js.source.yml')
end

test "adds paths to exceptions" do
random_path = SecureRandom.hex
@env.append_path(random_path)

error = assert_raises(Sprockets::FileNotFound) do
uri, _ = @env.resolve!("thisfiledoesnotexistandshouldraiseerrors", {})
uri
end

assert_match /#{ random_path }/, error.message
end

def resolve(path, options = {})
uri, _ = @env.resolve(path, options)
uri
Expand Down
3 changes: 2 additions & 1 deletion test/test_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ def app
test "re-throw JS exceptions in the browser" do
get "/assets/missing_require.js"
assert_equal 200, last_response.status
assert_equal "throw Error(\"Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application/javascript'\\n (in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)\")", last_response.body
assert_match /Sprockets::FileNotFound: couldn't find file 'notfound' with type 'application\/javascript'/, last_response.body
assert_match /(in #{fixture_path("server/vendor/javascripts/missing_require.js")}:1)/, last_response.body
end

test "display CSS exceptions in the browser" do
Expand Down

0 comments on commit a0e44ae

Please sign in to comment.