<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>&lt;p&gt;Here's a quick tip on how to test those helpers such as 'new_post_path' and 'home_path'. Also those formatted routes such as 'formatted_posts_path'. And why is important to test those.&lt;/p&gt;

&lt;p&gt;Here's how I test route helper methods.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
# spec/controllers/ideas_controller_spec.rb

describe IdeasController do
  describe &quot;GET /ideas/new&quot; do
    it &quot;should have helper method new_idea_path&quot; do
      get :new
      new_idea_path.should_not be_nil
      new_idea_path.should == '/ideas/new'
    end

    it &quot;should have helper method formatted_new_idea_path&quot; do
      get :new, :format =&gt; :json
      formatted_new_idea_path.should_not be_nil
      formatted_new_idea_path.should == '/ideas/new.json'
    end

    (...)
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And why it's important to test those methods, since they're already tested by Rails tests?&lt;/p&gt;

&lt;p&gt;Rails 2.3 has removed all those formatted_xxx named routes. Turns out these routes ate up a lot of memory and served minimal purpose. Read article &lt;a href=&quot;http://ryandaigle.com/articles/2008/11/27/what-s-new-in-edge-rails-no-more-formatted-routes
&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So if you use something like formatted_new_user, and you need to upgrade the application to Rails 2.3, it would be broken without test coverage.&lt;/p&gt;</body>
  <comments-count type="integer">16</comments-count>
  <created-at type="datetime">2009-02-07T18:19:39Z</created-at>
  <id type="integer">20</id>
  <permalink nil="true"></permalink>
  <slug></slug>
  <title>Testing route helper methods and formatted routes</title>
  <updated-at type="datetime">2009-02-07T18:19:39Z</updated-at>
  <user-id type="integer" nil="true"></user-id>
</post>
