Sha256: 39c013832ab444d6b8e7358ddd8bb9acc07aea6636327332a1a41192adfe4628

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "default_headers plugin" do 
  it "sets the default headers to use for the response" do
    h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}

    app(:bare) do
      plugin :default_headers, h
      route do |r|
      end
    end

    req[1].should == h
    req[1].should_not equal(h)
  end

  it "should not override existing default headers" do
    h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}

    app(:bare) do
      plugin :default_headers, h
      plugin :default_headers

      route do |r|
      end
    end

    req[1].should == h
  end

  it "should allow modifying the default headers at a later point" do
    h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}

    app(:bare) do
      plugin :default_headers
      default_headers['Content-Type'] = 'text/json'
      default_headers['Foo'] = 'bar'

      route do |r|
      end
    end

    req[1].should == h
  end

  it "should work correctly in subclasses" do
    h = {'Content-Type'=>'text/json', 'Foo'=>'bar'}

    app(:bare) do
      plugin :default_headers
      default_headers['Content-Type'] = 'text/json'
      default_headers['Foo'] = 'bar'

      route do |r|
      end
    end

    @app = Class.new(@app)
    @app.route{}

    req[1].should == h
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
roda-cj-1.0.5 spec/plugin/default_headers_spec.rb
roda-cj-1.0.4 spec/plugin/default_headers_spec.rb
roda-cj-1.0.3 spec/plugin/default_headers_spec.rb
roda-cj-1.0.2 spec/plugin/default_headers_spec.rb
roda-cj-1.0.1 spec/plugin/default_headers_spec.rb
roda-cj-1.0.0 spec/plugin/default_headers_spec.rb
roda-1.0.0 spec/plugin/default_headers_spec.rb
roda-cj-0.9.6 spec/plugin/default_headers_spec.rb
roda-cj-0.9.5 spec/plugin/default_headers_spec.rb
roda-cj-0.9.4 spec/plugin/default_headers_spec.rb
roda-cj-0.9.3 spec/plugin/default_headers_spec.rb
roda-cj-0.9.2 spec/plugin/default_headers_spec.rb
roda-cj-0.9.1 spec/plugin/default_headers_spec.rb
roda-0.9.0 spec/plugin/default_headers_spec.rb