diff --git a/lib/sprockets/manifest.rb b/lib/sprockets/manifest.rb index 9e6329e00..2d42c9f8b 100644 --- a/lib/sprockets/manifest.rb +++ b/lib/sprockets/manifest.rb @@ -161,7 +161,8 @@ def find_sources(*args) end else args.each do |path| - yield File.binread(File.join(dir, assets[path])) + asset = assets[path] + yield File.binread(File.join(dir, asset)) if asset end end end diff --git a/test/test_manifest.rb b/test/test_manifest.rb index 323bb3229..acef521ea 100644 --- a/test/test_manifest.rb +++ b/test/test_manifest.rb @@ -634,7 +634,13 @@ def teardown manifest = Sprockets::Manifest.new(@env, @dir) result = manifest.find_sources("mobile/a.js", "mobile/b.js") - assert_equal ["var A;\n", "var B;\n"], result.to_a + assert_equal ["var A;\n", "var B;\n"], result.to_a.sort + + result = manifest.find_sources("not_existent.js", "also_not_existent.js") + assert_equal [], result.to_a + + result = manifest.find_sources("mobile/a.js", "also_not_existent.js") + assert_equal ["var A;\n"], result.to_a end test "find_sources without environment" do @@ -645,6 +651,12 @@ def teardown result = manifest.find_sources("mobile/a.js", "mobile/b.js") assert_equal ["var A;\n", "var B;\n"], result.to_a + + result = manifest.find_sources("not_existent.js", "also_not_existent.js") + assert_equal [], result.to_a + + result = manifest.find_sources("mobile/a.js", "also_not_existent.js") + assert_equal ["var A;\n"], result.to_a end test "compress non-binary assets" do