Sha256: 3ab227b10723eb8dbf1a15dee686779904dd5fdd0c68f6e3123f6b7ecfdc660f

Contents?: true

Size: 873 Bytes

Versions: 9

Compression:

Stored size: 873 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

9 entries across 9 versions & 1 rubygems

Version Path
scorpion-ioc-1.0.10 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.8 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.7 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.6 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.4 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.3 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.2 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.1 spec/lib/scorpion/rack/middleware_spec.rb
scorpion-ioc-1.0.0 spec/lib/scorpion/rack/middleware_spec.rb