Sha256: 00a770aa5e2f0c3b28bb675635d412ef2922044e91cd61bf732956c0510e822c

Contents?: true

Size: 1.35 KB

Versions: 97

Compression:

Stored size: 1.35 KB

Contents

require "#{File.dirname(__FILE__)}/spec_setup"
require 'rack/cache/key'

describe 'A Rack::Cache::Key' do
  # Helper Methods =============================================================

  def mock_request(*args)
    uri, opts = args
    env = Rack::MockRequest.env_for(uri, opts || {})
    Rack::Cache::Request.new(env)
  end

  def new_key(request)
    Rack::Cache::Key.call(request)
  end

  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
end

Version data entries

97 entries across 73 versions & 19 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rack-cache-1.2/test/key_test.rb
swipe-rails-0.0.5 vendor/bundle/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/rack-cache-1.2/test/key_test.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/rack-cache-1.2/test/key_test.rb
challah-1.0.0.beta3 vendor/bundle/gems/rack-cache-1.2/test/key_test.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
challah-1.0.0.beta2 vendor/bundle/gems/rack-cache-1.2/test/key_test.rb
challah-1.0.0.beta vendor/bundle/gems/rack-cache-1.2/test/key_test.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.5 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb
active_mailer-0.0.4 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/test/key_test.rb