Sha256: e70e53960d8aa941bba743396ddf12b94ff9a59fed5cd7baa2a014839e9d8d37

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

require "spec_helper"

module BetterErrors
  describe ErrorPage do
    let(:exception) { raise ZeroDivisionError, "you divided by zero you silly goose!" rescue $! }
  
    let(:error_page) { ErrorPage.new exception, { "REQUEST_PATH" => "/some/path" } }
    
    let(:response) { error_page.render }
  
    it "should include the error message" do
      response.should include("you divided by zero you silly goose!")
    end
  
    it "should include the request path" do
      response.should include("/some/path")
    end
  
    it "should include the exception class" do
      response.should include("ZeroDivisionError")
    end
    
    context "when showing source code" do
      before do
        exception.stub!(:backtrace).and_return([
          "#{File.expand_path("../support/my_source.rb", __FILE__)}:8:in `some_method'"
        ])
      end
      
      it "should show the line where the exception was raised" do
        response.should include("8 eight")
      end
      
      it "should show five lines of context" do
        response.should include("3 three")
        response.should include("13 thirteen")
      end
      
      it "should not show more than five lines of context" do
        response.should_not include("2 two")
        response.should_not include("14 fourteen")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
better_errors-0.0.6 spec/better_errors/error_page_spec.rb
better_errors-0.0.5 spec/better_errors/error_page_spec.rb
better_errors-0.0.4 spec/better_errors/error_page_spec.rb
better_errors-0.0.3 spec/better_errors/error_page_spec.rb
better_errors-0.0.2 spec/better_errors/error_page_spec.rb
better_errors-0.0.1 spec/better_errors/error_page_spec.rb