Sha256: f5000e9b29ebee7353a4ca56fe3fc12ef9c069d4476473398feb38192d766f59
Contents?: true
Size: 1.1 KB
Versions: 21
Compression:
Stored size: 1.1 KB
Contents
require_relative "../spec_helper" 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 it "releases resources via body.close" do body = StringIO.new('hi') app(:head) do |r| r.root do r.halt [ 200, {}, body ] end end s, _, b = req('REQUEST_METHOD' => 'HEAD') s.must_equal 200 res = String.new body.closed?.must_equal false b.each { |buf| res << buf } b.close body.closed?.must_equal true res.must_equal '' end end
Version data entries
21 entries across 21 versions & 1 rubygems
Version | Path |
---|---|
roda-3.9.0 | spec/plugin/head_spec.rb |