From 8a505a26a9ac47d7697b4570faef3213eae5bec8 Mon Sep 17 00:00:00 2001 From: nex3 Date: Fri, 22 Dec 2006 06:59:38 +0000 Subject: [PATCH] Testing Sass' exception handling. git-svn-id: svn://hamptoncatlin.com/haml/trunk@243 7063305b-7217-0410-af8c-cdc13e5119b9 --- test/sass/plugin_test.rb | 25 ++++++++++++++++++++++++- test/sass/templates/bork.sass | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/sass/templates/bork.sass diff --git a/test/sass/plugin_test.rb b/test/sass/plugin_test.rb index 79da8456..026e395e 100644 --- a/test/sass/plugin_test.rb +++ b/test/sass/plugin_test.rb @@ -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 diff --git a/test/sass/templates/bork.sass b/test/sass/templates/bork.sass new file mode 100644 index 00000000..bf2634e9 --- /dev/null +++ b/test/sass/templates/bork.sass @@ -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.