Sha256: f611c8ba1e82ac78e028ebf1458bcf33c2abfdba6637a144581a6f1d1d2b5086

Contents?: true

Size: 840 Bytes

Versions: 20

Compression:

Stored size: 840 Bytes

Contents

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

describe "session handling" do
  it "should give a warning if session variable is not available" do
    app do |r|
      begin
        session
      rescue Exception => e
        e.message
      end
    end

    body.must_match(/use Rack::Session::Cookie/)
  end

  it "should return session if available" do
    app(:bare) do
      use Rack::Session::Cookie, :secret=>'1'

      route do |r|
        r.on do
          (session[1] ||= 'a'.dup) << 'b'
          session[1]
        end
      end
    end

    _, h, b = req
    b.join.must_equal 'ab'
    _, h, b = req('HTTP_COOKIE'=>h['Set-Cookie'].sub("; path=/; HttpOnly", ''))
    b.join.must_equal 'abb'
    _, h, b = req('HTTP_COOKIE'=>h['Set-Cookie'].sub("; path=/; HttpOnly", ''))
    b.join.must_equal 'abbb'
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
roda-2.29.0 spec/session_spec.rb
roda-2.28.0 spec/session_spec.rb
roda-2.27.0 spec/session_spec.rb
roda-2.26.0 spec/session_spec.rb
roda-2.25.0 spec/session_spec.rb
roda-2.24.0 spec/session_spec.rb
roda-2.23.0 spec/session_spec.rb
roda-2.22.0 spec/session_spec.rb
roda-2.21.0 spec/session_spec.rb
roda-2.20.0 spec/session_spec.rb
roda-2.19.0 spec/session_spec.rb
roda-2.18.0 spec/session_spec.rb
roda-2.17.0 spec/session_spec.rb
roda-2.16.0 spec/session_spec.rb
roda-2.15.0 spec/session_spec.rb
roda-2.14.0 spec/session_spec.rb
roda-2.13.0 spec/session_spec.rb
roda-2.12.0 spec/session_spec.rb
roda-2.11.0 spec/session_spec.rb
roda-2.10.0 spec/session_spec.rb