Sha256: 81befb74c67ba2665fca472f3d31743dcfb8fd0237113d47373329b112c9bbbf

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

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

def dumb_app(env)
  body = block_given? ? [yield] : ['Hi']
  [ 200, {'Content-Type' => 'text/plain'}, body ]
end

describe 'Rack::Cache::new' do
  before { @app = method(:dumb_app) }

  it 'takes a backend and returns a middleware component' do
    Rack::Cache.new(@app).
      should.respond_to :call
  end
  it 'takes an options Hash' do
    lambda { Rack::Cache.new(@app, {}) }.
      should.not.raise(ArgumentError)
  end
  it 'sets options provided in the options Hash' do
    object = Rack::Cache.new(@app, :foo => 'bar', 'foo.bar' => 'bling')
    object.options['foo.bar'].should.equal 'bling'
    object.options['rack-cache.foo'].should.equal 'bar'
  end
  it 'takes a block; executes it during initialization' do
    state, block_scope = 'not invoked', nil
    object =
      Rack::Cache.new @app do
        block_scope = self
        state = 'invoked'
        should.respond_to :on
      end
    state.should.equal 'invoked'
    object.should.be block_scope
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
rtomayko-rack-cache-0.3.0 test/cache_test.rb
rack-cache-0.3.0 test/cache_test.rb