File tree Expand file tree Collapse file tree 3 files changed +27
-21
lines changed
Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 33module Csscss ::Parser
44 module Background
55 describe Background do
6+ include CommonParserTests
7+
68 before do
79 @parser = Parser . new
810 @trans = Transformer . new
911 end
1012
11- def trans ( s )
12- @trans . apply ( @parser . parse ( s ) )
13- end
14-
1513 it "parses position" do
1614 @parser . bg_position . must_parse ( "10.2%" )
1715 @parser . bg_position . must_parse ( "left" )
@@ -47,11 +45,6 @@ def trans(s)
4745
4846 trans ( "#fff" ) . must_equal ( [ dec ( "background-color" , "#fff" ) ] )
4947 trans ( "BLACK" ) . must_equal ( [ dec ( "background-color" , "black" ) ] )
50- trans ( "inherit" ) . must_equal ( [ ] )
51- end
52-
53- it "doesn't parse unknown values" do
54- @parser . wont_parse ( "foo" )
5548 end
5649
5750 it "tries the parse and returns false if it doesn't work" do
Original file line number Diff line number Diff line change 33module Csscss ::Parser
44 module ListStyle
55 describe ListStyle do
6+ include CommonParserTests
7+
68 before do
79 @parser = Parser . new
810 @trans = Transformer . new
911 end
1012
11- def trans ( s )
12- @trans . apply ( @parser . parse ( s ) )
13- end
14-
1513 it "converts shorthand rules to longhand" do
1614 trans ( "circle outside url('foo.jpg')" ) . must_equal ( [
1715 dec ( "list-style-type" , "circle" ) ,
@@ -20,14 +18,6 @@ def trans(s)
2018 ] )
2119 end
2220
23- it "parses inherit" do
24- trans ( "inherit" ) . must_equal ( [ ] )
25- end
26-
27- it "doesn't parse unknown values" do
28- @parser . wont_parse ( "foo" )
29- end
30-
3121 it "tries the parse and returns false if it doesn't work" do
3222 @parser . try_parse ( "foo" ) . must_equal ( false )
3323 parsed = @parser . try_parse ( "circle" )
Original file line number Diff line number Diff line change @@ -38,3 +38,26 @@ def assert_not_parse(parser, string)
3838
3939Parslet ::Atoms ::DSL . infect_an_assertion :assert_parse , :must_parse , :do_not_flip
4040Parslet ::Atoms ::DSL . infect_an_assertion :assert_not_parse , :wont_parse , :do_not_flip
41+
42+ module CommonParserTests
43+ def self . included ( base )
44+ base . send ( :include , Helpers )
45+ base . instance_eval do
46+ describe "common tests" do
47+ it "parses inherit" do
48+ trans ( "inherit" ) . must_equal ( [ ] )
49+ end
50+
51+ it "doesn't parse unknown values" do
52+ @parser . wont_parse ( "foo" )
53+ end
54+ end
55+ end
56+ end
57+
58+ module Helpers
59+ def trans ( s )
60+ @trans . apply ( @parser . parse ( s ) )
61+ end
62+ end
63+ end
You can’t perform that action at this time.
0 commit comments