spec/less/parser_spec.rb in less-2.2.0 vs spec/less/parser_spec.rb in less-2.2.1

- old
+ new

@@ -17,10 +17,14 @@ it "accepts options when assembling the parse tree" do subject.parse(".class {width: 1+1}").to_css(:compress => true).strip.should eql ".class{width:2;}" end end + it "throws a ParseError if the lesscss is bogus" do + expect { subject.parse('{^)') }.should raise_error(Less::ParseError, /missing closing `\}`/) + end + it "passes exceptions from the less compiler" do expect { subject.parse('body { color: @a; }').to_css }.should raise_error(Less::ParseError, /variable @a is undefined/) end describe "when configured with multiple load paths" do @@ -33,9 +37,22 @@ it "passes exceptions from less imported less files" do expect { subject.parse('@import "faulty.less";').to_css }.should raise_error(Less::ParseError, /variable @a is undefined/) end + it "reports type, line, column and filename of (parse) error" do + begin + subject.parse('@import "faulty.less";').to_css + rescue Less::ParseError => e + e.type.should == 'Name' + e.filename.should == cwd.join('faulty/faulty.less').to_s + e.line.should == 1 + e.column.should == 16 + else + fail "parse error not raised" + end + end + end describe "when load paths are specified in as default options" do before do Less.paths << cwd.join('one')