Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appends load paths to error message with tests #322

Merged
merged 2 commits into from
Oct 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/sprockets/resolve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def resolve!(path, **kargs)

message << " with type '#{kargs[:accept]}'" if kargs[:accept]

load_paths = kargs[:load_paths] || config[:paths]
message << "\nChecked in these paths: \n #{ load_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