Sha256: b05c99ce8fe40d17d64a85b73fbc92059233a0b10324ec211ff183fd6742bd8c

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require 'rack/test'

describe SpeedGun::Middleware do
  include Rack::Test::Methods

  before(:all) do
    SpeedGun.config.skip_paths << '/skip'
  end

  let(:app) do
    builder = Rack::Builder.new do
      use SpeedGun::Middleware

      map '/skip' do
        process = lambda do |env|
          [
            200,
            { 'Content-Type' => 'text/html' },
            "<html><BODY><h1>Skip</h1></BODY>\n \t</html>"
          ]
        end

        run process
      end

      map '/html' do
        process = lambda do |env|
          [
            200,
            { 'Content-Type' => 'text/html' },
            "<html><BODY><h1>Hi</h1></BODY>\n \t</html>"
          ]
        end

        run process
      end
    end
    builder.to_app
  end

  describe 'GET /skip' do
    subject(:response) { get '/skip' }

    it { should be_ok }

    describe '#headers' do
      subject { response.headers }

      it { should_not be_has_key('X-SpeedGun-Profile-Id') }
    end
  end

  describe 'GET /html' do
    subject(:response) { get '/html' }

    it { should be_ok }

    describe '#headers' do
      subject { response.headers }

      it { should be_has_key('X-SpeedGun-Profile-Id') }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
speed_gun-1.0.0.rc1 spec/lib/speed_gun/middleware_spec.rb