File: content_type_spec.rb

package info (click to toggle)
ruby-http 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 404 kB
  • ctags: 213
  • sloc: ruby: 2,397; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download
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
41
42
43
44
45
46
47
require 'spec_helper'

describe HTTP::ContentType do
  describe '.parse' do
    context 'with text/plain' do
      subject { described_class.parse 'text/plain' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should be_nil }
    end

    context 'with tEXT/plaIN' do
      subject { described_class.parse 'tEXT/plaIN' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should be_nil }
    end

    context 'with text/plain; charset=utf-8' do
      subject { described_class.parse 'text/plain; charset=utf-8' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should eq 'utf-8' }
    end

    context 'with text/plain; charset="utf-8"' do
      subject { described_class.parse 'text/plain; charset="utf-8"' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should eq 'utf-8' }
    end

    context 'with text/plain; charSET=utf-8' do
      subject { described_class.parse 'text/plain; charSET=utf-8' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should eq 'utf-8' }
    end

    context 'with text/plain; foo=bar; charset=utf-8' do
      subject { described_class.parse 'text/plain; foo=bar; charset=utf-8' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should eq 'utf-8' }
    end

    context 'with text/plain;charset=utf-8;foo=bar' do
      subject { described_class.parse 'text/plain;charset=utf-8;foo=bar' }
      its(:mime_type) { should eq 'text/plain' }
      its(:charset)   { should eq 'utf-8' }
    end
  end
end