Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Test requiring missing absolute paths
Browse files Browse the repository at this point in the history
Fixes #196
  • Loading branch information
josh committed Sep 14, 2011
1 parent 8be6fd5 commit b8a7ae2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sprockets/asset_attributes.rb
Expand Up @@ -50,7 +50,7 @@ def logical_path
path = "#{path}#{engine_format_extension}" unless format_extension
path
else
raise Error, "#{pathname} isn't in paths: #{environment.paths.join(', ')}"
raise FileOutsidePaths, "#{pathname} isn't in paths: #{environment.paths.join(', ')}"
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/sprockets/errors.rb
Expand Up @@ -6,6 +6,7 @@ class CircularDependencyError < Error; end
class ContentTypeMismatch < Error; end
class EncodingError < Error; end
class FileNotFound < Error; end
class FileOutsidePaths < Error; end

module EngineError
attr_accessor :sprockets_annotation
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/asset/absolute/require_nonexistent_path.js
@@ -0,0 +1 @@
//= require_tree /missing
1 change: 1 addition & 0 deletions test/fixtures/asset/absolute/require_outside_path.js.erb
@@ -0,0 +1 @@
//= require /bin/sh
12 changes: 12 additions & 0 deletions test/test_asset.rb
Expand Up @@ -298,6 +298,12 @@ def setup
end
end

test "can't require absolute files outside the load path" do
assert_raise Sprockets::FileOutsidePaths do
warn asset("absolute/require_outside_path.js").to_s
end
end

test "require_directory requires all child files in alphabetical order" do
assert_equal(
"ok(\"b.js.erb\");\n",
Expand Down Expand Up @@ -345,6 +351,12 @@ def setup
end
end

test "require_tree with a nonexistent absolute path raises an exception" do
assert_raise(Sprockets::ArgumentError) do
asset("absolute/require_nonexistent_path.js").to_s
end
end

test "require_tree respects order of child dependencies" do
assert_equal(
"var c;\nvar b;\nvar a;\n\n",
Expand Down

0 comments on commit b8a7ae2

Please sign in to comment.