Sha256: c3704cec2883773e26c2917d25b824d11e9d803039597f63365a44cd7fda8f1a

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

require "#{File.dirname(__FILE__)}/spec_setup"

describe 'Rack::Cache::Response' do

  before(:each) {
    @now = Time.now
    @response = Rack::Cache::Response.new(200, {'Date' => @now.httpdate}, '')
    @one_hour_ago = Time.httpdate((Time.now - (60**2)).httpdate)
  }

  after(:each) {
    @now, @response, @one_hour_ago = nil
  }

  it 'responds to cache-related methods' do
    @response.should.respond_to :ttl
    @response.should.respond_to :age
    @response.should.respond_to :date
  end

  it 'responds to #to_a with a Rack response tuple' do
    @response.should.respond_to :to_a
    @response.to_a.should.be == [200, {'Date' => @now.httpdate}, '']
  end

  it 'retrieves headers with #[]' do
    @response.headers['X-Foo'] = 'bar'
    @response.should.respond_to :[]
    @response['X-Foo'].should.be == 'bar'
  end

  it 'sets headers with #[]=' do
    @response.should.respond_to :[]=
    @response['X-Foo'] = 'bar'
    @response.headers['X-Foo'].should.be == 'bar'
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
rtomayko-rack-cache-0.2.0 test/response_test.rb
rtomayko-rack-cache-0.3.0 test/response_test.rb
rack-cache-0.2.0 test/response_test.rb
rack-cache-0.3.0 test/response_test.rb