Added a check for XML well-formedness to assert_success

(optional, enabled by uncommenting a variable at the top of test_helper.rb);
corrected some malformed templates (not all yet)
This commit is contained in:
Alexey Verkhovsky 2005-01-23 16:34:27 +00:00
parent 203405c4dc
commit c8e459cbb0
4 changed files with 37 additions and 24 deletions

View file

@ -1,10 +1,12 @@
ENV['RAILS_ENV'] ||= 'test'
require File.dirname(__FILE__) + '/../config/environment'
require 'application'
require 'test/unit'
require 'action_controller/test_process'
# Uncomment this variable to have assert_success check that response bodies are valid XML
# $validate_xml_in_assert_success = true
# Convenient setup method for Test::Unit::TestCase
class Test::Unit::TestCase
@ -93,3 +95,21 @@ module ChunkMatch
end
end
if defined? $validate_xml_in_assert_success and $validate_xml_in_assert_success == true
module Test
module Unit
module Assertions
alias :__assert_success_before_ovverride_by_instiki :assert_success
def assert_success
__assert_success_before_ovverride_by_instiki
if @response.body.kind_of?(Proc)
body = @response.body.call
else
body = @response.body
end
assert_nothing_raised(body) { REXML::Document.new(body) }
end
end
end
end
end