<?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>Pillage and Plunder &#187; vim</title>
	<atom:link href="http://pillageandplunder.net/tag/vim/feed/" rel="self" type="application/rss+xml" />
	<link>http://pillageandplunder.net</link>
	<description>Viking's programming blog</description>
	<lastBuildDate>Tue, 25 Aug 2009 00:21:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>View spec names and Autotest</title>
		<link>http://pillageandplunder.net/2008/12/view-spec-names-and-autotest/</link>
		<comments>http://pillageandplunder.net/2008/12/view-spec-names-and-autotest/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 23:05:59 +0000</pubDate>
		<dc:creator>viking</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://pillageandplunder.net/?p=24</guid>
		<description><![CDATA[In one of my Rails projects, I have some views that are rendered through ERB and others through HAML.  This makes it annoying to jump to a view&#8217;s spec via rails.vim, since it currently doesn&#8217;t handle custom Rcommand&#8217;s that accept multiple suffixes.
When I asked tpope today about this, he brought up a good point. [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my Rails projects, I have some views that are rendered through ERB and others through HAML.  This makes it annoying to jump to a view&#8217;s spec via <a href="http://rails.vim.tpope.net">rails.vim</a>, since it currently doesn&#8217;t handle custom <code>Rcommand</code>&#8217;s that accept multiple suffixes.</p>
<p>When I asked <a href="http://tpope.net">tpope</a> today about this, he brought up a good point.  Why are view specs associated with an engine type (such as ERB or HAML) by default?  You should be able to convert an ERB view to a HAML view and use the same tests.</p>
<p>Per his tip, I renamed my views from names like <code>new.html.haml_spec.rb</code> to just <code>new.html_spec.rb</code>.  Unfortunately, autotest stopped recognizing the correlation between my views and my view specs.  Putting this in my <code>.autotest</code> file fixed the issue:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:initialize</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
  at.<span style="color:#9900CC;">remove_mapping</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">%</span>^app<span style="color:#006600; font-weight:bold;">/</span>views<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  at.<span style="color:#9900CC;">add_mapping</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">%</span>^app<span style="color:#006600; font-weight:bold;">/</span>views<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>.<span style="color:#006600; font-weight:bold;">*</span><span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f, md<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#008000; font-style:italic;"># strip off engine name</span>
    path = md<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">sub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\.<span style="color:#006600; font-weight:bold;">&#40;</span>erb<span style="color:#006600; font-weight:bold;">|</span>haml<span style="color:#006600; font-weight:bold;">&#41;</span>$<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    at.<span style="color:#9900CC;">files_matching</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span>spec<span style="color:#006600; font-weight:bold;">/</span>views<span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{path}_spec.rb})</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I hope that helps someone. <img src='http://pillageandplunder.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://pillageandplunder.net/2008/12/view-spec-names-and-autotest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
