Sha256: 5fe1e9b3174779db0186176d95b30f91da1379ee785258da69ad11d78aa3cc30

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

require 'spec'
require 'rubygems'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rack-tamperproof'

def build_builder(config, key = "testing this key", &block)
  app = Rack::Builder.new do
    if key
      use Rack::Tamperproof, :default_key => "testing this key", &config
    else
      use Rack::Tamperproof, &config
    end
    run build_app(& (block || Proc.new{ |a,b|
    }))
  end
  
end

def build_app(&block)
  Proc.new { |env|
    request = Rack::Request.new(env)
    Rack::Response.new do |response|
      response.body = ['hello']
      response.header['Content-type'] = 'text/plain'
      unless request.cookies['test']
        response.set_cookie('test', 'protected') 
      end
      block.call(request, response)
    end.to_a
  }
end

def build_cookie_header(cookies)
  cookies.map{|k,v| "#{Rack::Utils.escape(k)}=#{Rack::Utils.escape(v)}"}.join(';')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-tamperproof-0.0.1 spec/spec_helper.rb