Sha256: 980b09b1a86fae62796a8cb573834a01a2d570ba81eaf47fc32bb4ae92f30046

Contents?: true

Size: 807 Bytes

Versions: 9

Compression:

Stored size: 807 Bytes

Contents

require_relative "spec_helper"

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

9 entries across 9 versions & 1 rubygems

Version Path
roda-3.8.0 spec/session_spec.rb
roda-3.7.0 spec/session_spec.rb
roda-3.6.0 spec/session_spec.rb
roda-3.5.0 spec/session_spec.rb
roda-3.4.0 spec/session_spec.rb
roda-3.3.0 spec/session_spec.rb
roda-3.2.0 spec/session_spec.rb
roda-3.1.0 spec/session_spec.rb
roda-3.0.0 spec/session_spec.rb