From 2d4e0e400ff72af164e00aa28ebbd276a641f3b6 Mon Sep 17 00:00:00 2001 From: Michael Schubert & Sam Obukwelu Date: Thu, 8 Mar 2012 10:58:25 -0500 Subject: [PATCH] Fix for Compass.shared_extension_paths when HOME is a relative path. This should fully resolve https://github.com/chriseppstein/compass/issues/364 for when HOME is not just nil but also "." (or any other relative path). Added a complete set of unit tests around the method as well. --- lib/compass.rb | 2 ++ test/units/compass_module_test.rb | 36 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/units/compass_module_test.rb diff --git a/lib/compass.rb b/lib/compass.rb index 2d097fcb..1ac47c13 100644 --- a/lib/compass.rb +++ b/lib/compass.rb @@ -21,6 +21,8 @@ module Compass else [] end + rescue ArgumentError # If HOME is relative + [] end end module_function :base_directory, :lib_directory, :shared_extension_paths diff --git a/test/units/compass_module_test.rb b/test/units/compass_module_test.rb new file mode 100644 index 00000000..0e9e530b --- /dev/null +++ b/test/units/compass_module_test.rb @@ -0,0 +1,36 @@ +require File.join(File.dirname(__FILE__), "..", "test_helper") + +class CompassModuleTest < Test::Unit::TestCase + + def setup + Compass.reset_configuration! + Compass.instance_variable_set("@shared_extension_paths", nil) + @original_home = ENV["HOME"] + end + + def teardown + ENV["HOME"] = @original_home + Compass.reset_configuration! + end + + def test_shared_extension_paths_with_valid_home + ENV["HOME"] = "/" + assert_equal ["/.compass/extensions"], Compass.shared_extension_paths + end + + def test_shared_extension_paths_with_nil_home + ENV["HOME"] = nil + assert_equal [], Compass.shared_extension_paths + end + + def test_shared_extension_paths_with_file_home + ENV["HOME"] = __FILE__ + assert_equal [], Compass.shared_extension_paths + end + + def test_shared_extension_paths_with_relative_home + ENV["HOME"] = "." + assert_equal [], Compass.shared_extension_paths + end + +end