Sha256: 8cc5320aff6c7fd9ecf8771d92f446dff401041616bb7c1d7a1590378e27158a

Contents?: true

Size: 989 Bytes

Versions: 9

Compression:

Stored size: 989 Bytes

Contents

require "spec_helper"

describe "StaticMatic::Rescue" do
  before do
    setup_staticmatic
  end
  
  it "catch haml template errors" do
    output = @staticmatic.generate_html_with_layout("page_with_error")
    output.should match(/StaticMatic::TemplateError/)
  end
  
  it "catch sass template errors" do
    output = @staticmatic.generate_css("stylesheets/css_with_error")
    output.should match(/StaticMatic::TemplateError/)
  end
  
  it "re-raise and catch partial errors" do
    begin
      @staticmatic.generate_html("page_with_partial_error")
    rescue StaticMatic::TemplateError => template_error
      template_error.filename.should match(/partials\/partial_with_error/)
    end
  end
  
  it "handle non-template errors" do
    begin
      raise Exception.new("This is an exception")
    rescue Exception => e
      output = @staticmatic.render_rescue_from_error(e)
    end
    
    output.should match(/Exception/)
    output.should match(/This is an exception/)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
staticmatic2-2.1.8 spec/rescue_spec.rb
staticmatic2-2.1.7 spec/rescue_spec.rb
staticmatic2-2.1.6 spec/rescue_spec.rb
staticmatic2-2.1.5 spec/rescue_spec.rb
staticmatic2-2.1.4 spec/rescue_spec.rb
staticmatic2-2.1.3 spec/rescue_spec.rb
staticmatic2-2.1.2 spec/rescue_spec.rb
staticmatic2-2.1.1 spec/rescue_spec.rb
staticmatic2-2.1.0 spec/rescue_spec.rb