diff --git a/lib/sprockets/resolve.rb b/lib/sprockets/resolve.rb index e240471a9..d6cae616c 100644 --- a/lib/sprockets/resolve.rb +++ b/lib/sprockets/resolve.rb @@ -60,6 +60,7 @@ def resolve!(path, options = {}) end message << " with type '#{options[:accept]}'" if options[:accept] + message << "\nChecked in these paths: \n #{ config[:paths].join("\n ") }" raise FileNotFound, message end diff --git a/test/test_resolve.rb b/test/test_resolve.rb index 3c19d2f79..39017dd9b 100644 --- a/test/test_resolve.rb +++ b/test/test_resolve.rb @@ -251,6 +251,18 @@ def setup @env.each_logical_path("application.js", /gallery\.css/).to_a 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.merge(compat: false)) uri diff --git a/test/test_server.rb b/test/test_server.rb index 6fce22eb0..e69830690 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -283,7 +283,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