Permalink
Browse files

Do not fail if ENV['HOME'] is unset.

  • Loading branch information...
Rolf Timmermans
Rolf Timmermans committed May 25, 2011
1 parent 9ec864c commit aac188f3e3a047d51a8e663803511fb46120fc2d
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/sprockets/asset_attributes.rb
  2. +13 −0 test/test_asset.rb
@@ -19,7 +19,7 @@ def extensions
def pretty_path
@pretty_path ||= @pathname.
- sub(/^#{Regexp.escape(ENV['HOME'])}/, '~').
+ sub(/^#{Regexp.escape(ENV['HOME'] || '')}/, '~').
sub(/^#{Regexp.escape(environment.root)}\//, '')
end
View
@@ -361,6 +361,19 @@ def setup
assert_equal "@charset \"UTF-8\";\n.foo {}\n\n.bar {}\n", asset("charset.css").to_s
end
+ test "should not fail if home is not set in environment" do
+ begin
+ home, ENV["HOME"] = ENV["HOME"], nil
+ assert_nothing_raised do
+ env = Sprockets::Environment.new
+ env.append_path(fixture_path('asset'))
+ env['application.js']
+ end
+ ensure
+ ENV["HOME"] = home
+ end
+ end
+
def asset(logical_path)
@env.index[logical_path]
end

0 comments on commit aac188f

Please sign in to comment.