From 4e72e0c87105f8bc70bdd968c7ac445fc315b5d4 Mon Sep 17 00:00:00 2001 From: Sergey Avseyev Date: Thu, 28 Feb 2013 14:28:48 +0300 Subject: [PATCH] Fix tests for less 1.3.3 --- lib/less/defaults.rb | 2 +- lib/less/java_script/rhino_context.rb | 2 +- lib/less/java_script/v8_context.rb | 2 +- lib/less/loader.rb | 3 ++- spec/less/parser_spec.rb | 5 +++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/less/defaults.rb b/lib/less/defaults.rb index 36a7344..05646de 100644 --- a/lib/less/defaults.rb +++ b/lib/less/defaults.rb @@ -2,7 +2,7 @@ module Less module Defaults def defaults - @defaults ||= { :paths => [] } + @defaults ||= { :paths => [], :relativeUrls => true } end def paths diff --git a/lib/less/java_script/rhino_context.rb b/lib/less/java_script/rhino_context.rb index 8b5cb25..d593fce 100644 --- a/lib/less/java_script/rhino_context.rb +++ b/lib/less/java_script/rhino_context.rb @@ -74,7 +74,7 @@ def handle_js_error(e) if e.value && ( e.value['message'] || e.value['type'].is_a?(String) ) raise Less::ParseError.new(e, e.value) # LessError end - if e.unwrap.to_s == "missing closing `}`" + if e.unwrap.to_s =~ /missing closing `}`/ raise Less::ParseError.new(e.unwrap.to_s) end if e.message && e.message[0, 12] == "Syntax Error" diff --git a/lib/less/java_script/v8_context.rb b/lib/less/java_script/v8_context.rb index e942720..e67eca4 100644 --- a/lib/less/java_script/v8_context.rb +++ b/lib/less/java_script/v8_context.rb @@ -77,7 +77,7 @@ def lock(&block) # }, env); # # comes back as value: RuntimeError ! - elsif e.value.to_s == "missing closing `}`" + elsif e.value.to_s =~ /missing closing `}`/ raise Less::ParseError.new(e.value.to_s) end raise Less::Error.new(e) diff --git a/lib/less/loader.rb b/lib/less/loader.rb index f291b5c..a7dffdd 100644 --- a/lib/less/loader.rb +++ b/lib/less/loader.rb @@ -31,7 +31,8 @@ def require(module_id) class Path def join(*components) - File.join(*components) + # node.js expands path on join + File.expand_path(File.join(*components)) end def dirname(path) diff --git a/spec/less/parser_spec.rb b/spec/less/parser_spec.rb index 5247358..6aba101 100644 --- a/spec/less/parser_spec.rb +++ b/spec/less/parser_spec.rb @@ -42,8 +42,9 @@ it "will track imported files" do subject.parse('@import "one.less";') subject.parse('@import "two.less";') - subject.imports.should include("one.less") - subject.imports.should include("two.less") + # Parser#imports returns full path names + subject.imports.grep(/one\.less$/).should_not be_empty + subject.imports.grep(/two\.less$/).should_not be_empty end it "reports type, line, column and filename of (parse) error" do