Sha256: db7cc014d624211b175ed4585dfdb8415b23e17b33bf133d18ce4d291a7ed601

Contents?: true

Size: 1.67 KB

Versions: 36

Compression:

Stored size: 1.67 KB

Contents

# frozen_string_literal: true

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

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

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

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

    context "with text/plain; charSET=utf-8" do
      subject { described_class.parse "text/plain; charSET=utf-8" }
      its(:mime_type) { is_expected.to eq "text/plain" }
      its(:charset)   { is_expected.to 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) { is_expected.to eq "text/plain" }
      its(:charset)   { is_expected.to 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) { is_expected.to eq "text/plain" }
      its(:charset)   { is_expected.to eq "utf-8" }
    end
  end
end

Version data entries

36 entries across 36 versions & 3 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/http-5.2.0/spec/lib/http/content_type_spec.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
http-5.2.0 spec/lib/http/content_type_spec.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/spec/lib/http/content_type_spec.rb
http-5.1.1 spec/lib/http/content_type_spec.rb
http-5.1.0 spec/lib/http/content_type_spec.rb
http-5.0.4 spec/lib/http/content_type_spec.rb
http-5.0.3 spec/lib/http/content_type_spec.rb
http-5.0.2 spec/lib/http/content_type_spec.rb
http-5.0.1 spec/lib/http/content_type_spec.rb
http-5.0.0 spec/lib/http/content_type_spec.rb
http-4.4.1 spec/lib/http/content_type_spec.rb
http-4.4.0 spec/lib/http/content_type_spec.rb
http-5.0.0.pre3 spec/lib/http/content_type_spec.rb
http-5.0.0.pre2 spec/lib/http/content_type_spec.rb
http-4.3.0 spec/lib/http/content_type_spec.rb