Undefined Range : Tag rails, everything about rails http://www.undefinedrange.com/tag/rails.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 Rails String Core Extensions Cheatsheet <p><a href="http://undefinedrange.com/files/strings_cheatsheet.png"><img src="http://undefinedrange.com/files/strings_cheatsheet_thumbnail.png" /></a></p> <p><a href="http://undefinedrange.com/files/strings_cheatsheet.png"><span class="caps">PNG</span></a> <a href="http://undefinedrange.com/files/strings_cheatsheet.pdf"><span class="caps">PDF</span></a></p> <p><br /> <br /> References<br /> <a href ="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Access.html">/CoreExtensions/String/Access.html</a><br /> <a href ="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Conversions.html">/CoreExtensions/String/Conversions.html</a><br /> <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html">/CoreExtensions/String/Inflections.html</a><br /> <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Iterators.html">/CoreExtensions/String/Iterators.html</a><br /> <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/StartsEndsWith.html">/CoreExtensions/String/StartsEndsWith.html</a><br /> <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Unicode.html">/CoreExtensions/String/Unicode.html</a><br /> <a href="http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Time/Conversions.html">/CoreExtensions/Time/Conversions.html</a><br /> <a href="http://www.ruby-forum.com/topic/57923">Changing default date format in Rails @ Ruby Forum</a><br /> <a href="http://errtheblog.com/post/44">Rails Rubyisms Advent @ errtheblog.com</p> Mon, 16 Jul 2007 15:43:00 -0700 urn:uuid:3242ac3a-d6a6-4724-ae0a-183838fe02c4 blog@undefinedrange.com (Vincent Woo) http://www.undefinedrange.com/2007/07/16/rails-string-core-extensions-cheatsheet#comments Ruby on Rails Portfolio cheatsheet rails string extensions inflections unicode http://www.undefinedrange.com/trackbacks?article_id=rails-string-core-extensions-cheatsheet&day=16&month=07&year=2007 http://www.undefinedrange.com/2007/07/16/rails-string-core-extensions-cheatsheet Simply Restful Cheatsheet <p>It was recently incorporated into Rails proper so it seemed like a good time to dive into the Simply Restful functionality. Not much documentation exists for it but many blogs have already posted tutorials.</p> <p>The results of the past day or two&#8217;s tinkering distilled into a single 8.5 <span class="caps">X 11</span> sheet:<br /> <a href="http://www.undefinedrange.com/files/rest.png"><img src="http://www.undefinedrange.com/files/rest-thumb.png" alt="" /></a><br /></p> <p><a href="http://www.undefinedrange.com/files/rest.png">.png</a> <a href="http://www.undefinedrange.com/files/rest.pdf">.pdf</a></p> <p><br /> References<br /> <a href="http://www.ryandaigle.com/articles/2006/05/30/whats-new-in-edge-rails-restful-method-support-in-link-helpers">Ryan&#8217;s Scraps (1)</a><br /> <a href="http://www.ryandaigle.com/articles/2006/08/01/whats-new-in-edge-rails-simply-restful-support-and-how-to-use-it">Ryan&#8217;s Scraps (2)</a><br /> <a href="http://scottraymond.net/articles/2006/07/20/refactoring-to-rest">scottraymondnet</a><br /> <a href="http://weblog.rubyonrails.com/2006/8/1/simply-restful-in-rails-edge">Riding Rails</a><br /> <a href="http://metaatem.net/2006/07/31/rest-and-rails-no-reason-to-be-scared">Meta|ateM</a><br /> <a href="http://anthonyeden.com/articles/2006/07/25/playing-with-simply-restful-plugin">anthonyeden.com</a></p> Sat, 19 Aug 2006 15:27:00 -0700 urn:uuid:ebdd0754-eefa-4acf-8959-1dea57a250f7 blog@undefinedrange.com (Vincent Woo) http://www.undefinedrange.com/2006/08/19/simply-restful-cheatsheet#comments Ruby on Rails cheatsheet restful routes rails mime http://www.undefinedrange.com/trackbacks?article_id=simply-restful-cheatsheet&day=19&month=08&year=2006 http://www.undefinedrange.com/2006/08/19/simply-restful-cheatsheet