1
0

parser_test.rb 694 B

12345678910111213141516171819202122232425262728
  1. require 'test_helper'
  2. require 'docs'
  3. class DocsParserTest < MiniTest::Spec
  4. def parser(content)
  5. Docs::Parser.new(content)
  6. end
  7. describe "#html" do
  8. it "returns a Nokogiri Node" do
  9. assert_kind_of Nokogiri::XML::Node, parser('').html
  10. end
  11. context "with an HTML fragment" do
  12. it "returns the fragment" do
  13. body = '<div>Test</div>'
  14. assert_equal body, parser(body).html.inner_html
  15. end
  16. end
  17. context "with an HTML document" do
  18. it "returns the <body>" do
  19. body = '<!doctype html><meta charset=utf-8><title></title><div>Test</div>'
  20. assert_equal '<div>Test</div>', parser(body).html.inner_html
  21. end
  22. end
  23. end
  24. end