Sha256: c32ab0c90d3ddb0da6eecd92e5e197063e4a3c94efefea86c1b7cde3078b7544

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
http-0.6.4 spec/http/content_type_spec.rb
http-0.6.3 spec/http/content_type_spec.rb
http-0.6.2 spec/http/content_type_spec.rb
http-0.6.1 spec/http/content_type_spec.rb
http-0.6.0 spec/http/content_type_spec.rb
http-0.6.0.pre spec/http/content_type_spec.rb