Topic: rails3 and rspec2 - no route matches

Hi, I have some problem with my fresh application based on ror 3.0.3. My rspec test for controller:

require 'spec_helper'

describe TasksController do

  describe "GET #index" do
    before(:each) do
      @tasks = [mock_model(Task), mock_model(Task)]
      get :index
    it { assigns(:tasks).should eq(@tasks) }
    it { assert_template("index")}

  describe "GET #new" do
    before(:each) do
      get :new
    it { assert_template("new")}


unfortunetly it fails when try to get new action:

  1) TasksController GET #new 
     Failure/Error: get :new
       No route matches {:controller=>"tasks", :action=>"new"}

There is no problem with this action routes in browser and cucumber scenarios. I also typed rake routes to be sure:

 tasks GET    /tasks(.:format)          {:action=>"index", :controller=>"tasks"}
          POST   /tasks(.:format)          {:action=>"create", :controller=>"tasks"}
 new_task GET    /tasks/new(.:format)      {:action=>"new", :controller=>"tasks"}
edit_task GET    /tasks/:id/edit(.:format) {:action=>"edit", :controller=>"tasks"}
     task GET    /tasks/:id(.:format)      {:action=>"show", :controller=>"tasks"}
          PUT    /tasks/:id(.:format)      {:action=>"update", :controller=>"tasks"}
          DELETE /tasks/:id(.:format)      {:action=>"destroy", :controller=>"tasks"}
     root        /(.:format)               {:controller=>"tasks", :action=>"index"}

and my routes.rb file:

Timetracker::Application.routes.draw do

  resources :tasks, :expect => [:edit, :update]

  root :to => "tasks#index"


I have no idea what is the reason of this error. Someone can help me? Any suggestion?

Re: rails3 and rspec2 - no route matches

Hi Piotr,

how did you fix this? I am having exactly the same problem. My site is working, but inside rspec2 i keep getting these errors that no route matches, although it is a valid controller.

Re: rails3 and rspec2 - no route matches

It was mispelling in routes, ":expect" intstead of ":except"