Testing Sass' exception handling.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@243 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2006-12-22 06:59:38 +00:00
parent 65d95f907a
commit 8a505a26a9
2 changed files with 26 additions and 1 deletions

View File

@ -34,7 +34,21 @@ class SassPluginTest < Test::Unit::TestCase
assert !Sass::Plugin.stylesheet_needs_update?('basic')
end
def assert(*args)
def test_exception_handling
File.open(tempfile_loc('bork')) do |file|
assert file.gets == "bork bork bork!\n"
end
File.delete(tempfile_loc('bork'))
Sass.const_set('RAILS_ENV', 'production')
raised = false
begin
Sass::Plugin.update_stylesheets
rescue
raised = true
end
assert raised
assert !File.exists?(tempfile_loc('bork'))
Sass::Plugin.const_set('RAILS_ENV', 'testing')
end
def test_controller_process
@ -70,6 +84,15 @@ module Sass::Plugin
end
end
class Sass::Engine
alias_method :old_render, :render
def render
raise "bork bork bork!" if @template[0] == "{bork now!}"
old_render
end
end
class ActionController::Base
def sass_old_process(*args); end
end

View File

@ -0,0 +1,2 @@
{bork now!}
This template isn't actually Sass. It's designed to make the interpreter choke, to test the exception-handling code.