Sha256: 3dad8d1f4108e8bf4ab9750e6c6a70b4b1e676f5ee55c4923feeda7416e711c4
Contents?: true
Size: 1.38 KB
Versions: 31
Compression:
Stored size: 1.38 KB
Contents
require "#{File.dirname(__FILE__)}/spec_setup" require 'rack/cache/key' describe 'A Rack::Cache::Key' do it "sorts params" do request = mock_request('/test?z=last&a=first') new_key(request).should.include('a=first&z=last') end it "includes the scheme" do request = mock_request( '/test', 'rack.url_scheme' => 'https', 'HTTP_HOST' => 'www2.example.org' ) new_key(request).should.include('https://') end it "includes host" do request = mock_request('/test', "HTTP_HOST" => 'www2.example.org') new_key(request).should.include('www2.example.org') end it "includes path" do request = mock_request('/test') new_key(request).should.include('/test') end it "sorts the query string by key/value after decoding" do request = mock_request('/test?x=q&a=b&%78=c') new_key(request).should.match(/\?a=b&x=c&x=q$/) end it "is in order of scheme, host, path, params" do request = mock_request('/test?x=y', "HTTP_HOST" => 'www2.example.org') new_key(request).should.equal "http://www2.example.org/test?x=y" end # Helper Methods ============================================================= define_method :mock_request do |*args| uri, opts = args env = Rack::MockRequest.env_for(uri, opts || {}) Rack::Cache::Request.new(env) end define_method :new_key do |request| Rack::Cache::Key.call(request) end end
Version data entries
31 entries across 31 versions & 6 rubygems