Sha256: 96f7b255dc04349305747139093c9741b4c0b6f099806e33d7252bb249ef656c

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require File.dirname(__FILE__) + "/test_helper"

class StaticMatic::RescueTest < Test::Unit::TestCase
  def setup
    setup_staticmatic
  end
  
  should "catch haml template errors" do
    output = @staticmatic.generate_html_with_layout("page_with_error")
    assert_match /StaticMatic::TemplateError/, output 
  end
  
  should "catch sass template errors" do
    output = @staticmatic.generate_css("css_with_error")
    assert_match /StaticMatic::TemplateError/, output 
  end
  
  should "re-raise and catch partial errors" do
    begin
      @staticmatic.generate_html("page_with_partial_error")
    rescue StaticMatic::TemplateError => template_error
      assert_match /partials\/partial_with_error/, template_error.filename
    end
  end
  
  should "handle non-template errors" do
    begin
      raise Exception.new("This is an exception")
    rescue Exception => e
      output = @staticmatic.render_rescue_from_error(e)
    end
    
    assert_match /Exception/, output
    assert_match /This is an exception/, output
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bdimcheff-staticmatic-0.10.1 test/rescue_test.rb
staticmatic-0.10.2 test/rescue_test.rb