<?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>Cory O&#039;Daniel - These are just words &#187; testing</title>
	<atom:link href="http://coryodaniel.com/index.php/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing 404/500, Error Pages with Webrat visit method</title>
		<link>http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/</link>
		<comments>http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 19:02:09 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[webrat]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=508</guid>
		<description><![CDATA[This is a super simple snippet, and maybe there is something built into webrat, but I didn't find it. I needed to test for 404 pages in some of my tests (I was writing tests that made sure a page didnt show for disabled content). Purposely getting 404's can be annoying though since webrat opens [...]]]></description>
			<content:encoded><![CDATA[<p>This is a super simple snippet, and maybe there is something built into webrat, but I didn't find it. I needed to test for 404 pages in some of my tests (I was writing tests that made sure a page didnt show for disabled content). Purposely getting 404's can be annoying though since webrat opens up the 404 page in your default browser. There is a variable available in Webrat's configuration that you can use to temporarily disable this functionality. I wrapped it in the following method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> visit_but_dont_open<span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    Webrat.<span style="color:#9900CC;">configuration</span>.<span style="color:#9900CC;">instance_variable_set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@open_error_files&quot;</span>, <span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    visit url
    Webrat.<span style="color:#9900CC;">configuration</span>.<span style="color:#9900CC;">instance_variable_set</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;@open_error_files&quot;</span>, <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Throw that in your test_helper and you can start doing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">visit_but_dont_open <span style="color:#996600;">&quot;Http://example.com/page/that/doesnt/exist&quot;</span>
assert !response.<span style="color:#9900CC;">ok</span>?</pre></td></tr></table></div>

<p>Yay, 404.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Testing+404%2F500%2C+Error+Pages+with+Webrat+visit+method+http://bit.ly/ay7jfn" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/&amp;title=Testing+404%2F500%2C+Error+Pages+with+Webrat+visit+method" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/&amp;t=Testing+404%2F500%2C+Error+Pages+with+Webrat+visit+method" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/&amp;title=Testing+404%2F500%2C+Error+Pages+with+Webrat+visit+method" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/&amp;title=Testing+404%2F500%2C+Error+Pages+with+Webrat+visit+method" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/06/14/testing-404500-error-pages-with-webrat-visit-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

