Guest User

Untitled

a guest
Apr 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. ## rspec
  2.  
  3. it "should parse selectors and comments in the right order" do
  4. class DocumentTestHandler2 < CSS::SAC::DocumentHandler
  5. attr_reader :results
  6. def initialize
  7. @results = []
  8. end
  9. def start_selector(selectors)
  10. @results = @results + selectors.map(&:to_css)
  11. end
  12. def end_selector(selectors)
  13. @results << :end_selector
  14. end
  15. def comment(text)
  16. @results << :comment
  17. end
  18. end
  19.  
  20. parser = CSS::SAC::Parser.new(DocumentTestHandler2.new)
  21. source = <<-CSS
  22. .foo { font-size: 1px; }
  23. h2 { width: 100px; }
  24. /**
  25. * Comment
  26. */
  27. .test { color: white; }
  28. div {
  29. /* works */
  30. height: 100%;
  31. }
  32. CSS
  33. doc = parser.parse(source)
  34. doc.results.should == [".foo", :end_selector, "h2", :end_selector, :comment, ".test", :end_selector, "div", :comment, :end_selector]
  35. end
  36.  
  37. ## Result [plain_text]
  38.  
  39. 'ProjectFileHandler should parse selectors and comments in the right order' FAILED
  40. expected: [".foo", :end_selector, "h2", :end_selector, :comment, ".test", :end_selector, "div", :comment, :end_selector],
  41. got: [".foo", :end_selector, "h2", :comment, :end_selector, ".test", :end_selector, "div", :comment, :end_selector] (using ==)
Add Comment
Please, Sign In to add comment