Sha256: d2723219b1df2a43541b2e3dfc32e4c6076d761d102d5c97a920031d31d26f8f

Contents?: true

Size: 874 Bytes

Versions: 15

Compression:

Stored size: 874 Bytes

Contents

require "spec_helper"
require "scorpion/rack/middleware"

describe Scorpion::Rack::Middleware do
  let(:app)      { proc{ [ 200, {}, [ 'Sting!' ] ] } }
  let(:stack)    { Scorpion::Rack::Middleware.new( app ) }
  let(:request)  { Rack::MockRequest.new( stack ) }
  let(:response) { request.get('/') }

  it "creates a scorpion" do
    expect( stack ).to receive( :prepare_scorpion ).and_call_original
    response
  end

  it "prepares it with the environment" do
    proc = ->(env) {
        scorpion = env[Scorpion::Rack::Middleware::ENV_KEY]
        expect( scorpion.fetch( Scorpion::Rack::Env) ).to be env
      app.call( env )
    }

    request  = Rack::MockRequest::new( Scorpion::Rack::Middleware.new( proc ) )
    request.get '/'
  end

  it "frees the scorpion on return" do
    expect( stack ).to receive( :free_scorpion ).and_call_original
    response
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
scorpion-ioc-0.6.2 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.6.1 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.6.0 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.23 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.22 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.21 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.20 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.19 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.18 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.17 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.16 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.15 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.14 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.13 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-0.5.12 spec/lib/scorpion/rack/middleware_spec.rb