<?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>Able Technology &#187; rspec</title>
	<atom:link href="http://www.abletech.co.nz/tag/rspec/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.abletech.co.nz</link>
	<description>Web Application Programmers and Consultants</description>
	<lastBuildDate>Tue, 06 Dec 2011 03:01:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>False-positive validation warnings</title>
		<link>http://www.abletech.co.nz/2009/03/false-positive-validation-warnings/</link>
		<comments>http://www.abletech.co.nz/2009/03/false-positive-validation-warnings/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 00:48:21 +0000</pubDate>
		<dc:creator>nigel</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.abletech.co.nz/?p=197</guid>
		<description><![CDATA[I had been getting some validation warnings when running some of my specs. The W3 validator confirmed that my xHTML was valid. ignoring attempt to close div with input opened at byte 6028, line 108 closed at byte 6131, line 109 attributes at open: {&#8220;class&#8221;=>&#8221;form_field&#8221;} text around open: &#8220;r\&#8221;> \n \n \n]]></description>
			<content:encoded><![CDATA[<p>I had been getting some validation warnings when running some of my specs. The W3 validator confirmed that my xHTML was valid.</p>
<p><textarea name="code" class="ruby"><br />
ignoring attempt to close div with input<br />
  opened at byte 6028, line 108<br />
  closed at byte 6131, line 109<br />
  attributes at open: {&#8220;class&#8221;=>&#8221;form_field&#8221;}<br />
  text around open: &#8220;r\&#8221;></div>
</div>
<p>\n
<div class=\"form_fie"<br />
  text around close: "mit\" value=\"Log in\"></input>
<p>\n</p></div>
<p>\n</di"<br />
</textarea></p>
<p>After some googling of the problem, it turns out there is a difference between how xhtml and html documents are handled. Essentially, you need to tell the parser that the document is xHTML rather than HTML. More details <a href="http://marklunds.com/articles/one/336">here</a>, <a href="http://weblog.jamisbuck.org/2007/1/4/assert_xml_select">here</a>, and <a href="http://dev.rubyonrails.org/ticket/1937">here</a>.</p>
<p>The solution is to tell RSpec that the document is XML based. The options given in the links above work for RUnit based tests. Taking a look at the rspec source, it is checking to see if the response is XML based by noting the Content-Type header record. So, here&#8217;s the solution I used:</p>
<p><textarea name="code" class="ruby"><br />
before(:each) do<br />
  get :new, :id => scenarios(:abletech_pre_clicked_links).id<br />
  response.headers['Content-Type'] = <img src='http://www.abletech.co.nz/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> ml<br />
end<br />
</textarea></p>
<p>Now, when I run my specs, it correctly parses the response as XHTML and passes validation without any warnings.</p>
<p><textarea name="code" class="ruby"><br />
it &#8216;should show two forms&#8217; do<br />
  response.should have_tag(&#8216;div.form_step&#8217;, 2)<br />
end<br />
</textarea></p>
]]></content:encoded>
			<wfw:commentRss>http://www.abletech.co.nz/2009/03/false-positive-validation-warnings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
