Sha256: 14ff20110618b8e852bdbc9f1933bc4872ad1cf6accfc4c04abc7268d0742e16

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

describe 'route formatting' do

  describe 'setting the default route format' do
    subject { ::Rails.application.assets.context_class.new nil, nil, nil }

    it { should respond_to( :route_format ) }

    context 'default format' do
      its( :route_format ){ should eq( '.json' ) }
    end

    context 'as a symbol' do
      before do
        Eastwood.default_route_format = :xml
      end

      its( :route_format ){ should eq( '.xml' ) }
    end

    context 'as a string' do
      before do
        Eastwood.default_route_format = 'html'
      end

      its( :route_format ){ should eq( '.html' ) }
    end

    context 'when empty string' do
      before do
        Eastwood.default_route_format = ''
      end

      its( :route_format ){ should eq( '' ) }
    end

    context 'when false' do
      before do
        Eastwood.default_route_format = false
      end

      its( :route_format ){ should eq( '' ) }
    end
  end

  describe 'including the format in routes' do
    let( :context ){ ::Rails.application.assets.context_class.new nil, nil, nil }
    subject { context.routes[ :match ] }

    context 'default format' do
      its( :coffee_args ){ should eq( "format='.json'" ) }
    end

    context 'custom format' do
      before do
        Eastwood.default_route_format = :xml
      end

      its( :coffee_args ){ should eq( "format='.xml'" ) }
    end

    context 'omit format' do
      before do
        Eastwood.default_route_format = false
      end

      its( :coffee_args ){ should eq( "format=''" ) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eastwood-0.3.8 spec/unit/format_spec.rb
eastwood-0.3.7 spec/unit/format_spec.rb
eastwood-0.3.5 spec/unit/format_spec.rb
eastwood-0.3.2 spec/unit/format_spec.rb