Sha256: 0f05170aa4639dacda32e78ff2809bf6dd1111ed8f2a3ae2cdd09d61e3afc97e

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Acfs::Response::Formats do
  let(:status)    { 200 }
  let(:mime_type) { 'application/unknown' }
  let(:headers)   { {'Content-Type' => mime_type} }
  let(:request)   { Acfs::Request.new 'fubar' }
  let(:body)      { nil }
  let(:response)  { Acfs::Response.new request, status: status, headers: headers, body: body }

  context 'without Content-Type header' do
    let(:headers)   { {} }

    it "should fallback on 'text/plain'" do
      expect(response.content_type).to be == Mime[:text]
    end
  end

  context 'with JSON mimetype' do
    let(:mime_type) { 'application/json' }

    describe '#content_type' do
      it 'should return Mime::JSON' do
        expect(response.content_type).to be == Mime[:json]
      end
    end

    describe '#json?' do
      it 'should return true' do
        expect(response).to be_json
      end
    end

    context 'with charset option' do
      let(:mime_type) { 'application/json; charset=utf8' }

      describe '#content_type' do
        it 'should return Mime::JSON' do
          expect(response.content_type).to be == Mime[:json]
        end
      end

      describe '#json?' do
        it 'should return true' do
          expect(response).to be_json
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
acfs-1.3.2 spec/acfs/response/formats_spec.rb
acfs-1.3.1 spec/acfs/response/formats_spec.rb
acfs-1.3.0 spec/acfs/response/formats_spec.rb
acfs-1.2.1 spec/acfs/response/formats_spec.rb
acfs-0.50.0 spec/acfs/response/formats_spec.rb
acfs-1.2.0 spec/acfs/response/formats_spec.rb
acfs-0.49.1 spec/acfs/response/formats_spec.rb
acfs-1.1.1 spec/acfs/response/formats_spec.rb
acfs-0.49.0 spec/acfs/response/formats_spec.rb
acfs-1.1.0 spec/acfs/response/formats_spec.rb