Sha256: abd8d5421337773e411413e0c431b8c8407eb72ed72afd3f3a57c86d78dbf2b8

Contents?: true

Size: 1013 Bytes

Versions: 5

Compression:

Stored size: 1013 Bytes

Contents

require 'spec_helper'
module Alf
  module Rack
    describe Response, '.renderer' do

      subject{ Response.renderer({"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/yaml' do
        let(:accept){ "text/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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-rack-0.16.3 spec/response/class/test_renderer.rb
alf-rack-0.16.2 spec/response/class/test_renderer.rb
alf-rack-0.16.1 spec/response/class/test_renderer.rb
alf-rack-0.16.0 spec/response/class/test_renderer.rb
alf-rack-0.15.0 spec/response/class/test_renderer.rb