Sha256: e97520aad5409cf686004e75de2a299458da8d51bb4a092278cc4cd1530acf9b

Contents?: true

Size: 941 Bytes

Versions: 5

Compression:

Stored size: 941 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Low::Middleware::RequestId do
  def app
    app = lambda do |env|
      [200, {'Content-Type' => 'text/plain'}, ['Request Id: ' + env['useless.request_id']]]
    end

    Low::Middleware::RequestId.new(app)
  end

  it 'should add a request ID to the env while proxying transparently' do
    res = Rack::MockRequest.new(app).get('http://useless.info')
    res.should be_ok
    res.body.should =~ /Request Id: [a-z0-9]{1,}/
  end

  it 'should use the ID specified in the query parameter' do
    res = Rack::MockRequest.new(app).get('http://useless.info?request_id=jah')
    res.should be_ok
    res.body.should == 'Request Id: jah'
  end

  it 'should not use the ID specified it does not have "simple" characters' do
    res = Rack::MockRequest.new(app).get('http://useless.info?request_id=(jah)')
    res.should be_ok
    res.body.should_not == 'Request Id: (jah)'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
low-0.0.12 spec/low/middleware/request_id_spec.rb
low-0.0.11 spec/low/middleware/request_id_spec.rb
low-0.0.10 spec/low/middleware/request_id_spec.rb
low-0.0.9 spec/low/middleware/request_id_spec.rb
low-0.0.8 spec/low/middleware/request_id_spec.rb