Undefined Range : Tag rspec, everything about rspec http://www.undefinedrange.com/tag/rspec.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 Rake task runs both Test::Unit and RSpec tests <p>I&#8217;m in the middle of converting tests from Test::Unit to RSpec in an older Rails project. So far so good although I&#8217;m sure that would change as I dive into more complicated test cases. Still, I&#8217;m hoping the pain is worth it for the multiple contexts and lessened fixture reliance.</p> <p>A nifty feature that I accidentally stumbled upon is that the default rake task would run the test in both test and spec directories. It&#8217;s not like I have to exclusively choose one or the other.</p> <p>That opens up lots of test conversion options. I could convert the tests all at once or a little at a time. Or I could forget about conversion completely and merely write new tests in RSpec.</p> <p>It&#8217;s little surprises like this that brightens up my workday.</p> <p><span class="caps">UPDATE</span> (FEB8,08): RSpec tests won&#8217;t run unless all Test::Unit tests passes.</p> Fri, 18 Jan 2008 19:04:00 -0800 urn:uuid:7abea194-30e6-48ac-a4dd-42f8100a8a87 blog@undefinedrange.com (Vincent Woo) http://www.undefinedrange.com/2008/01/18/rake-task-runs-both-test-unit-and-rspec-tests#comments Ruby on Rails rake rails test bdd rspec http://www.undefinedrange.com/trackbacks?article_id=rake-task-runs-both-test-unit-and-rspec-tests&day=18&month=01&year=2008 http://www.undefinedrange.com/2008/01/18/rake-task-runs-both-test-unit-and-rspec-tests