Sha256: c74598e169f43813471df36aa4624e9e775ccc56d23089db8e2ec54cc1b94619

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

require "spec_helper"

module BetterErrors
  describe Middleware do
    it "should pass non-error responses through" do
      app = Middleware.new(->env { ":)" })
      app.call({}).should == ":)"
    end
    
    context "when handling an error" do
      let(:app) { Middleware.new(->env { raise "oh no :(" }) }
    
      it "should return status 500" do
        status, headers, body = app.call({})
      
        status.should == 500
      end
    
      it "should return UTF-8 error pages" do
        status, headers, body = app.call({})
        
        headers["Content-Type"].should == "text/html; charset=utf-8"
      end
      
      it "should log the exception" do
        logger = Object.new
        logger.should_receive :fatal
        BetterErrors.stub!(:logger).and_return(logger)
        
        app.call({})
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
better_errors-0.2.0 spec/better_errors/middleware_spec.rb
better_errors-0.1.1 spec/better_errors/middleware_spec.rb
better_errors-0.1.0 spec/better_errors/middleware_spec.rb
better_errors-0.0.8 spec/better_errors/middleware_spec.rb