Sha256: e57b411287124033ca7cd77e313618c291fa92ac09179c1124679e06469f49d0

Contents?: true

Size: 1.35 KB

Versions: 17

Compression:

Stored size: 1.35 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe Rack::Harakiri do
  before(:each) do
    @app = stub :app
  end
  context "defaults" do
    before(:each) do
      @harakiri = Rack::Harakiri.new @app
    end
    it "should quit after an amount of requests" do
      @harakiri.quit_after_requests.should == 50
    end
    describe "harakiri" do
      it "should kill the process after 50 harakiri calls" do
        Process.should_receive(:kill).once
        
        50.times { @harakiri.harakiri }
      end
      it "should not kill the process after 49 harakiri calls" do
        Process.should_receive(:kill).never
        
        49.times { @harakiri.harakiri }
      end
    end
    describe "call" do
      before(:each) do
        @app.stub! :call
        @app.stub! :harakiri
      end
      it "calls harakiri" do
        @harakiri.should_receive(:harakiri).once.with
        
        @harakiri.call :env
      end
      it "calls the app" do
        @app.should_receive(:call).once.with :env
        
        @harakiri.call :env
      end
    end
  end
  context "with harakiri set" do
    before(:each) do
      Rack::Harakiri.after = 100
      @harakiri = Rack::Harakiri.new @app
    end
    after(:each) do
      Rack::Harakiri.after = nil
    end
    it "should quit after an amount of requests" do
      @harakiri.quit_after_requests.should == 100
    end
  end
  
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
picky-0.12.3 spec/lib/rack/harakiri_spec.rb
picky-0.12.2 spec/lib/rack/harakiri_spec.rb
picky-0.12.1 spec/lib/rack/harakiri_spec.rb
picky-0.12.0 spec/lib/rack/harakiri_spec.rb
picky-0.11.2 spec/lib/rack/harakiri_spec.rb
picky-0.11.1 spec/lib/rack/harakiri_spec.rb
picky-0.11.0 spec/lib/rack/harakiri_spec.rb
picky-0.10.5 spec/lib/rack/harakiri_spec.rb
picky-0.10.4 spec/lib/rack/harakiri_spec.rb
picky-0.10.2 spec/lib/rack/harakiri_spec.rb
picky-0.10.1 spec/lib/rack/harakiri_spec.rb
picky-0.10.0 spec/lib/rack/harakiri_spec.rb
picky-0.9.4 spec/lib/rack/harakiri_spec.rb
picky-0.9.3 spec/lib/rack/harakiri_spec.rb
picky-0.9.2 spec/lib/rack/harakiri_spec.rb
picky-0.9.1 spec/lib/rack/harakiri_spec.rb
picky-0.9.0 spec/lib/rack/harakiri_spec.rb