Sha256: d494f73107278723e290852fb2e2b24934a932e5039194ba49124b46f9f0c1ad

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

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


describe Bullet::Rack do
  let(:middleware) { Bullet::Rack.new app }
  let(:app) { AppDouble.new }

  describe "#call" do
    context "when Bullet is enabled" do
      before(:each) { Bullet.enable = true }

      it "should invoke Bullet.start_request" do
        Bullet.should_receive(:start_request)
        middleware.call([])
      end

      it "should invoke Bullet.end_request" do
        Bullet.should_receive(:end_request)
        middleware.call([])
      end

      it "should return original response body" do
        expected_response = ResponseDouble.new "Actual body"
        app.response = expected_response
        status, headers, response = middleware.call([])
        response.should eq expected_response
      end
    end

    context "when Bullet is disabled" do
      before(:each) { Bullet.enable = false }
      after(:each) { Bullet.enable = true }

      it "should not call Bullet.start_request" do
        Bullet.should_not_receive(:start_request)
        middleware.call([])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bullet-2.2.1 spec/bullet/rack_spec.rb
bullet-2.2.0 spec/bullet/rack_spec.rb