title: ActionView::Template::Error: No route matches in rspec
body: <p>I have an error on my spec test and I don't know how to fix it: </p>
  
  <pre><code>An error occurred in an after hook
    ActionView::Template::Error: No route matches {:controller=&gt;"users", :action=&gt;"show", :name=&gt;#&lt;User id: 1, email: "testspec@gmail.com", encrypted_password: "$2a$04$z8LP2/rW7vhP9lYQ2bSrCeZ5ASYG2O8XUgRwI3/1R2aJ...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2013-05-01 17:21:03", last_sign_in_at: "2013-05-01 17:21:03", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", created_at: "2013-05-01 17:20:59", updated_at: "2013-05-01 17:21:03", name: nil, role: "user"&gt;}
    occurred at /Users/ejiqpep/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:533:in `raise_routing_error'
  </code></pre>
  
  <p>My test is:</p>
  
  <pre><code> before(:each) do
      user = FactoryGirl.create(:user)
      login_as(user, :scope =&gt; :user)
    end
    it "shouldn't allow user to delete last ingredient field", :js =&gt; true do
      visit new_recipe_path
      current_path.should == new_recipe_path
      click_link('Remove')
      page.should have_css('.ingredients-form')
    end
  </code></pre>
  
  <p>The problem is in my layout page. When I comment this line all works. But on my own I can click that link and get an error only in tests.</p>
  
  <pre><code>= link_to current_user.email, current_user, :class =&gt; 'btn'
  </code></pre>
  
  <p>users_controller.rb</p>
  
  <pre><code>class UsersController &lt; ApplicationController
    def show
      @user = User.find_by_name(params[:id])
    end
  end
  </code></pre>
  
  <p>routes.rb</p>
  
  <pre><code>EcookRails::Application.routes.draw do
    devise_for :users
    devise_scope :user do
      get '/login' =&gt; 'devise/sessions#new'
      post '/login' =&gt; 'devise/sessions#create'
      get '/logout' =&gt; 'devise/sessions#destroy'
      get '/register' =&gt; 'devise/registrations#new'
    end
    resources :recipes
    resources :users
  
    match 'favorites/:recipe_id' =&gt; 'favorites#create', :as =&gt; :favorite
    root :to =&gt; 'recipes#index'
  
  end
  </code></pre>
  
  <p>i think the problem can be in my user loggining in rspec. I use the Devise method to authorize in capybara.</p>
  
  <p>my rake routes output:</p>
  
  <pre><code> new_user_session GET    /users/sign_in(.:format)        devise/sessions#new
              user_session POST   /users/sign_in(.:format)        devise/sessions#create
      destroy_user_session DELETE /users/sign_out(.:format)       devise/sessions#destroy
             user_password POST   /users/password(.:format)       devise/passwords#create
         new_user_password GET    /users/password/new(.:format)   devise/passwords#new
        edit_user_password GET    /users/password/edit(.:format)  devise/passwords#edit
                           PUT    /users/password(.:format)       devise/passwords#update
  cancel_user_registration GET    /users/cancel(.:format)         devise/registrations#cancel
         user_registration POST   /users(.:format)                devise/registrations#create
     new_user_registration GET    /users/sign_up(.:format)        devise/registrations#new
    edit_user_registration GET    /users/edit(.:format)           devise/registrations#edit
                           PUT    /users(.:format)                devise/registrations#update
                           DELETE /users(.:format)                devise/registrations#destroy
                     login GET    /login(.:format)                devise/sessions#new
                           POST   /login(.:format)                devise/sessions#create
                    logout GET    /logout(.:format)               devise/sessions#destroy
                  register GET    /register(.:format)             devise/registrations#new
                   recipes GET    /recipes(.:format)              recipes#index
                           POST   /recipes(.:format)              recipes#create
                new_recipe GET    /recipes/new(.:format)          recipes#new
               edit_recipe GET    /recipes/:id/edit(.:format)     recipes#edit
                    recipe GET    /recipes/:id(.:format)          recipes#show
                           PUT    /recipes/:id(.:format)          recipes#update
                           DELETE /recipes/:id(.:format)          recipes#destroy
                     users GET    /users(.:format)                users#index
                           POST   /users(.:format)                users#create
                  new_user GET    /users/new(.:format)            users#new
                 edit_user GET    /users/:id/edit(.:format)       users#edit
                      user GET    /users/:id(.:format)            users#show
                           PUT    /users/:id(.:format)            users#update
                           DELETE /users/:id(.:format)            users#destroy
                  favorite        /favorites/:recipe_id(.:format) favorites#create
                      root        /                               recipes#index
  </code></pre>