Sha256: 5fc170819093758e8aa4cd2465088f55f715b2b8329230a1cfb0031986ccab56

Contents?: true

Size: 979 Bytes

Versions: 17

Compression:

Stored size: 979 Bytes

Contents

require "spec_helper"
require "shamu/rack"

module QueryParamsMiddlewareSpec
  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::QueryParamsMiddleware do
  let(:app)                     { QueryParamsMiddlewareSpec::App.new }
  let(:scorpion_middleware)     { Scorpion::Rack::Middleware.new( query_parmas_middleware ) }
  let(:query_parmas_middleware) { Shamu::Rack::QueryParamsMiddleware.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|
      query_parmas = app.send( :scorpion, env ).fetch Shamu::Rack::QueryParams
      expect( query_parmas ).to be_a Shamu::Rack::QueryParams
      [ 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/query_params_middleware_spec.rb
shamu-0.0.21 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.20 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.19 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.18 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.17 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.15 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.14 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.13 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.11 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.9 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.8 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.7 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.5 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.4 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.3 spec/lib/shamu/rack/query_params_middleware_spec.rb
shamu-0.0.2 spec/lib/shamu/rack/query_params_middleware_spec.rb