皆さん、こんにちは。この問題があります (投稿のタイトル)。
Failure/Error: get :create, :user => { :email => 'foo@example.com', :name => 'userexample' }
ActionController::RoutingError:No route matches {:action=>"show", :controller=>"user", :id=>nil}
これが私のUserController
です。
class UserController < ApplicationController
def new
end
def create
@user = User.new(params[:user])
@user.save
redirect_to :action => :show, :id => @user.id
end
def show
@user = User.find(params[:id])
end
end
ここに私のroutes.rbがあります
::Application.routes.draw do
devise_for :users
root :to => "user#index"
resources :user
#match "newuser" => "user#new"
get "user/new"
post "user/create"
get "user/:id" => "user#show"
そして、ここに私のrspecテストがあります
require 'spec/spec_helper'
describe UserController do
it "create new user" do
get :create, :user => { :email => 'foo@example.com', :name => 'userexample' }
flash[:notice] = 'new user was successfully created.'
end
end
end