Sha256: 45d8c05f1f86e96ffa616a81d3fced8891921dd5a7335babcd85ee8077e36d92

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

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

2 entries across 2 versions & 1 rubygems

Version Path
staticmatic3-2.1.10 spec/rescue_spec.rb
staticmatic3-2.1.9 spec/rescue_spec.rb