Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## rspec
- it "should parse selectors and comments in the right order" do
- class DocumentTestHandler2 < CSS::SAC::DocumentHandler
- attr_reader :results
- def initialize
- @results = []
- end
- def start_selector(selectors)
- @results = @results + selectors.map(&:to_css)
- end
- def end_selector(selectors)
- @results << :end_selector
- end
- def comment(text)
- @results << :comment
- end
- end
- parser = CSS::SAC::Parser.new(DocumentTestHandler2.new)
- source = <<-CSS
- .foo { font-size: 1px; }
- h2 { width: 100px; }
- /**
- * Comment
- */
- .test { color: white; }
- div {
- /* works */
- height: 100%;
- }
- CSS
- doc = parser.parse(source)
- doc.results.should == [".foo", :end_selector, "h2", :end_selector, :comment, ".test", :end_selector, "div", :comment, :end_selector]
- end
- ## Result [plain_text]
- 'ProjectFileHandler should parse selectors and comments in the right order' FAILED
- expected: [".foo", :end_selector, "h2", :end_selector, :comment, ".test", :end_selector, "div", :comment, :end_selector],
- got: [".foo", :end_selector, "h2", :comment, :end_selector, ".test", :end_selector, "div", :comment, :end_selector] (using ==)
Add Comment
Please, Sign In to add comment