File: xml_spec.rb

package info (click to toggle)
ruby-rouge 4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,844 kB
  • sloc: ruby: 38,489; sed: 2,071; perl: 152; makefile: 8
file content (40 lines) | stat: -rw-r--r-- 1,459 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*- #
# frozen_string_literal: true

describe Rouge::Lexers::XML do
  let(:subject) { Rouge::Lexers::XML.new }
  let(:bom) { "\xEF\xBB\xBF" }

  describe 'guessing' do
    include Support::Guessing

    it 'guesses by filename' do
      assert_guess :filename => 'foo.xml'
      assert_guess :filename => 'foo.xsl'
      assert_guess :filename => 'foo.rss'
      assert_guess :filename => 'foo.xslt'
      assert_guess :filename => 'foo.xsd'
      assert_guess :filename => 'foo.wsdl'
      assert_guess :filename => 'foo.svg'
      assert_guess :filename => 'foo.plist', :source => '<?xml version="1.0" encoding="utf-8"?>'
      deny_guess   :filename => 'foo.plist', :source => 'foo'
    end

    it 'guesses by mimetype' do
      assert_guess :mimetype => 'text/xml'
      assert_guess :mimetype => 'application/xml'
      assert_guess :mimetype => 'image/svg+xml'
      assert_guess :mimetype => 'application/rss+xml'
      assert_guess :mimetype => 'application/atom+xml'
    end

    it 'guesses by source' do
      assert_guess :source => '<?xml version="1.0" encoding="utf-8"?>'
      assert_guess :source => %{#{bom}<?xml version="1.0" encoding="utf-8"?>}
      assert_guess :source => '<?xml version="1.0" ?><html destdir="${reportfolderPath}" encoding="utf-8" />'
      assert_guess :source => '<!DOCTYPE xml>'
      deny_guess   :source => '<!DOCTYPE html>'
      assert_guess :source => '<!DOCTYPE unknown>'
    end
  end
end