Sha256: 840ebfc1568448fd131d2bc09d6e7dd72b147d39358d481e9f4f475cba2ae8cf

Contents?: true

Size: 920 Bytes

Versions: 17

Compression:

Stored size: 920 Bytes

Contents

require "spec_helper"
require "shamu/rack"

module CookiesMiddlewareSpec
  class App
    include Scorpion::Rack
    attr_accessor :next

    def call( env )
      @next ||= proc { [ 200, {}, [ "Sting!" ] ] }
      @next.call( env, self )
    end
  end
end

describe Shamu::Rack::CookiesMiddleware do
  let(:app)                 { CookiesMiddlewareSpec::App.new }
  let(:scorpion_middleware) { Scorpion::Rack::Middleware.new( cookies_middleware ) }
  let(:cookies_middleware)  { Shamu::Rack::CookiesMiddleware.new( app ) }
  let(:request)             { Rack::MockRequest.new( scorpion_middleware ) }
  let(:response)            { request.get( "/" ) }

  it "prepares it with the environment" do

    app.next = proc do |env, app|
      cookies = app.send( :scorpion, env ).fetch Shamu::Rack::Cookies
      expect( cookies ).to be_a Shamu::Rack::Cookies
      [ 200, {}, [ "Yum!" ] ]
    end

    request.get "/"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.21 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.20 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.19 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.18 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.17 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.15 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.14 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.13 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.11 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.9 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.8 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.7 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.5 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.4 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.3 spec/lib/shamu/rack/cookies_middleware_spec.rb
shamu-0.0.2 spec/lib/shamu/rack/cookies_middleware_spec.rb