<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Preston Lee&#039;s Blog &#187; xml</title>
	<atom:link href="http://www.prestonlee.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.prestonlee.com</link>
	<description>Technologist, businessman and entrepreneur.</description>
	<lastBuildDate>Tue, 24 Aug 2010 18:41:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rails 2.0: Testing For Well-Formed XML With assert_well_formed</title>
		<link>http://www.prestonlee.com/2007/12/22/rails-20-testing-for-well-formed-xml-with-assert_well_formed/</link>
		<comments>http://www.prestonlee.com/2007/12/22/rails-20-testing-for-well-formed-xml-with-assert_well_formed/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 08:15:31 +0000</pubDate>
		<dc:creator>preston.lee</dc:creator>
				<category><![CDATA[computer]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.prestonlee.com/archives/170</guid>
		<description><![CDATA[Here&#8217;s an easy way to validate that you&#8217;re always rendering well-formed HTML in an ordinary Rails application. I&#8217;ve written and verified this on Rails 2.0.1&#8230; First, define the custom assert_well_formed assertion in your test_helper.rb, like so&#8230; require 'rexml/document' class Test::Unit::TestCase def assert_well_formed assert_block "HTTP response was not well-formed XML." do   begin   REXML::Document.new(@response.body) true [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an easy way to validate that you&#8217;re always rendering well-formed HTML in an ordinary Rails application. I&#8217;ve written and verified this on Rails 2.0.1&#8230;</p>
<p><span id="more-170"></span></p>
<p>First, define the custom <em>assert_well_formed</em> assertion in your test_helper.rb, like so&#8230;</p>
<p><code>require 'rexml/document'</code></p>
<p><code>class Test::Unit::TestCase<br />
</code></p>
<blockquote><p><code>def assert_well_formed</code></p></blockquote>
<blockquote>
<blockquote><p><code> assert_block "HTTP response was not well-formed XML." do</code></p></blockquote>
<p> </p></blockquote>
<blockquote>
<blockquote>
<blockquote><p><code> begin</code></p></blockquote>
</blockquote>
<p> </p></blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote><p><code>REXML::Document.new(@response.body)</code><br />
<code> true</code></p></blockquote>
</blockquote>
</blockquote>
</blockquote>
<blockquote>
<blockquote>
<blockquote><p><code> rescue Exception =&gt; e</code></p></blockquote>
</blockquote>
<p> </p></blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote><p><code> false</code></p></blockquote>
</blockquote>
</blockquote>
<p> </p></blockquote>
<blockquote>
<blockquote>
<blockquote><p><code> end</code></p></blockquote>
</blockquote>
<p> </p></blockquote>
<blockquote>
<blockquote><p><code> end</code></p></blockquote>
<p> </p></blockquote>
<blockquote><p><code> end</code></p></blockquote>
<p><code> end</code></p>
<p>Then, in your functional test case, use it like this&#8230;</p>
<p><code>def test_index<br />
</code></p>
<blockquote><p><code> set_basic_authentication</code><br />
<code> get :index</code><br />
<code> assert_well_formed</code><br />
<code> assert_response :success</code></p></blockquote>
<p><code> end</code></p>
<p>That&#8217;s it!</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.prestonlee.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.prestonlee.com/2007/12/22/rails-20-testing-for-well-formed-xml-with-assert_well_formed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
