Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The error is because you're passing an entire URL to a method that expects a name of one of the controller's action methods. If I understand correctly, you're trying to test several things at once.</p> <p>Testing that a route has a name is different from testing a route is different from testing a controller action. Here's how I test a controller action (this probably comes as no surprise). Note that I'm matching your naming, not recommending what I'd use.</p> <p>In spec/controllers/articles_controller_spec.rb,</p> <pre><code>describe ArticlesController do describe '#permalink' do it "renders the page" do # The action and its parameter are both named permalink get :permalink :permalink =&gt; 666 response.should be_success # etc. end end end </code></pre> <p>Here's how I test a named route with only rspec-rails:</p> <p>In spec/routing/articles_routing_spec.rb,</p> <pre><code>describe ArticlesController do describe 'permalink' do it 'has a named route' do articles_permalink(666).should == '/permalink/666' end it 'is routed to' do { :get =&gt; '/permalink/666' }.should route_to( :controller =&gt; 'articles', :action =&gt; 'permalink', :id =&gt; '666') end end end </code></pre> <p>Shoulda's route matcher is more succinct while still providing a nice description and failure message:</p> <pre><code>describe ArticlesController do describe 'permalink' do it 'has a named route' do articles_permalink(666).should == '/permalink/666' end it { should route(:get, '/permalink/666').to( :controller =&gt; 'articles', :action =&gt; 'permalink', :id =&gt; '666' }) end end </code></pre> <p>AFAIK neither RSpec nor Shoulda have a specific, concise way of testing named routes, but you could write your own matcher.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload