Undefined Range : Tag tests, everything about tests http://www.undefinedrange.com/tag/tests.rss en-us 40 RSpec Tips <p>Since I&#8217;ve been following <a href="http://weblog.jamisbuck.org/2007/1/29/testing-your-views">Jamis Buck&#8217;s advice</a> to limit the brittleness of view tests, development has been much more productive. Test the things that matter most else you&#8217;ll end up with diminishing returns and the week passed by without any productive work done.</p> <p>I&#8217;m taking one step further and I&#8217;ve decided not to write RSpec view specifications.</p> <p>I will still continue to occasionally test important view elements. It just isn&#8217;t worth the extra baggage of writing and maintaining another set of specs for every single view. I&#8217;m feeling the pain there and I&#8217;m taking steps to eliminating it.</p> <p>But it is also painful to sprinkle &#8220;integrate_views&#8221; syntactic vinegar throughout controller specifications. I don&#8217;t want to do without that since I would still get notified of template errors. Unfortunately, this is not the recommended behavior and not much was written on the subject.</p> <p><a href="http://www.marklunds.com/articles/one/367">Peter Marklund</a> has a solution but it didn&#8217;t work for me. Maybe because RSpec was updated since his blog post was written but it is more likely that I&#8217;m missing something obvious. However, I dug around the plugin and was happy to discover a simple method override that worked. Add to spec_helper.rb:</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">module </span><span class="module">Spec</span> <span class="keyword">module </span><span class="module">Rails</span> <span class="keyword">module </span><span class="module">Example</span> <span class="keyword">class </span><span class="class">ControllerExampleGroup</span> <span class="keyword">module </span><span class="module">ControllerInstanceMethods</span> <span class="keyword">def </span><span class="method">integrate_views?</span> <span class="constant">true</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> <p>btw, while browsing the RSpec mailing list, I came across a post that explains <a href="http://rubyforge.org/pipermail/rspec-users/2008-March/006509.html">a way to slightly speed up test runs</a>.</p> Tue, 15 Apr 2008 14:53:00 -0700 urn:uuid:d7f8c48b-fb7c-4daf-bebb-6b14e901447d blog@undefinedrange.com (Vincent Woo) http://www.undefinedrange.com/2008/04/15/rspec-tips#comments Ruby on Rails rspec rails tests override http://www.undefinedrange.com/trackbacks?article_id=rspec-tips&day=15&month=04&year=2008 http://www.undefinedrange.com/2008/04/15/rspec-tips