Sha256: cc8de0636f56bc6f9d3b7b10a6d17f4d99069efa521793a76379240293986e3d

Contents?: true

Size: 931 Bytes

Versions: 1

Compression:

Stored size: 931 Bytes

Contents

require 'spec_helper'
module Alf
  describe Renderer, "from_http_accept" do

    subject{ Renderer.from_http_accept(accept) }

    context 'application/json' do
      let(:accept){ "application/json" }

      it{ should be(Renderer::JSON) }
    end

    context 'text/plain' do
      let(:accept){ "text/plain" }

      it{ should be(Renderer::Text) }
    end

    context 'text/csv' do
      let(:accept){ "text/csv" }

      it{ should be(Renderer::CSV) }
    end

    context 'text/x-yaml' do
      let(:accept){ "text/x-yaml" }

      it{ should be(Renderer::YAML) }
    end

    context '*/*' do
      let(:accept){ "*/*" }

      it{ should be(Renderer::JSON) }
    end

    context 'text/unknown' do
      let(:accept){ "text/unknown" }

      it{ should be(nil) }
    end

    context 'a complex one' do
      let(:accept){ "text/unknown, text/*;q=0.8, */*;q=0.5" }

      it{ should be(Renderer::CSV) }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-rest-0.14.0 spec/unit/ext/renderer/test_from_http_accept.rb