Sha256: 7a2ed55edf596cfc8d6c13d6a3ab935c84454649c573d13acea77190b2fe2792

Contents?: true

Size: 1.76 KB

Versions: 6

Compression:

Stored size: 1.76 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, { "PATH_INFO" => "/some/path" } }
    
    let(:response) { error_page.render }
    
    let(:empty_binding) {
      local_a = :value_for_local_a
      local_b = :value_for_local_b
      
      @inst_c = :value_for_inst_c
      @inst_d = :value_for_inst_d
      
      binding
    }
  
    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 "variable inspection" do
      let(:exception) { empty_binding.eval("raise") rescue $! }
      
      it "should show local variables" do
        html = error_page.do_variables("index" => 0)[:html]
        html.should include("local_a")
        html.should include(":value_for_local_a")
        html.should include("local_b")
        html.should include(":value_for_local_b")
      end
      
      it "should show instance variables" do
        html = error_page.do_variables("index" => 0)[:html]
        html.should include("inst_c")
        html.should include(":value_for_inst_c")
        html.should include("inst_d")
        html.should include(":value_for_inst_d")
      end
    end
    
    it "should not die if the source file is not a real filename" do
      exception.stub!(:backtrace).and_return([
        "<internal:prelude>:10:in `spawn_rack_application'"
      ])
      response.should include("Source unavailable")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
better_errors-0.7.2 spec/better_errors/error_page_spec.rb
better_errors-0.7.0 spec/better_errors/error_page_spec.rb
better_errors-0.6.0 spec/better_errors/error_page_spec.rb
better_errors-0.5.0 spec/better_errors/error_page_spec.rb
better_errors-0.3.2 spec/better_errors/error_page_spec.rb
better_errors-0.3.0 spec/better_errors/error_page_spec.rb