Sha256: 7224c1d6b807bfec570b6bc8d3198df5d73a3d7c67912e1046347986adc39553

Contents?: true

Size: 779 Bytes

Versions: 28

Compression:

Stored size: 779 Bytes

Contents

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

describe "head plugin" do 
  it "considers HEAD requests as GET requests which return no body" do
    app(:head) do |r|
      r.root do
        'root'
      end

      r.get 'a' do
        'a'
      end

      r.is 'b', :method=>[:get, :post] do
        'b'
      end
    end

    s, h, b = req
    s.must_equal 200
    h['Content-Length'].must_equal '4'
    b.must_equal ['root']

    s, h, b = req('REQUEST_METHOD' => 'HEAD')
    s.must_equal 200
    h['Content-Length'].must_equal '4'
    b.must_equal []

    body('/a').must_equal 'a'
    status('/a', 'REQUEST_METHOD' => 'HEAD').must_equal 200

    body('/b').must_equal 'b'
    status('/b', 'REQUEST_METHOD' => 'HEAD').must_equal 200
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
roda-2.9.0 spec/plugin/head_spec.rb
roda-2.8.0 spec/plugin/head_spec.rb
roda-2.7.0 spec/plugin/head_spec.rb
roda-2.6.0 spec/plugin/head_spec.rb
roda-2.5.1 spec/plugin/head_spec.rb
roda-2.5.0 spec/plugin/head_spec.rb
roda-2.4.0 spec/plugin/head_spec.rb
roda-2.3.0 spec/plugin/head_spec.rb