Ruby on rails 测试设计使用Rspec更新用户注册信息并获取:ActionController::UnknownFormat:错误
我只是尝试使用下面的代码来测试通过Rspec请求规范中的设计路径更新用户的电子邮件,我想知道为什么它会给我错误:Ruby on rails 测试设计使用Rspec更新用户注册信息并获取:ActionController::UnknownFormat:错误,ruby-on-rails,rspec,devise,rspec-rails,Ruby On Rails,Rspec,Devise,Rspec Rails,我只是尝试使用下面的代码来测试通过Rspec请求规范中的设计路径更新用户的电子邮件,我想知道为什么它会给我错误:ActionController::UnknownFormat: require 'rails_helper' RSpec.describe "UsersEdits", type: :request do let(:user) { FactoryGirl.create(:user) } it "my test" do email = "new@email.com"
ActionController::UnknownFormat:
require 'rails_helper'
RSpec.describe "UsersEdits", type: :request do
let(:user) { FactoryGirl.create(:user) }
it "my test" do
email = "new@email.com"
params = { "user[email]" => email, "user[current_password]" => 'foobar' }
put user_registration_path(user), params
user.reload
expect(user.email).to eq(email)
end
end
以下是错误:
Failure/Error: patch user_registration_path(user), params
ActionController::UnknownFormat:
ActionController::UnknownFormat
任何帮助都将不胜感激,谢谢 我自己刚查完
user\u registration\u path(user)
将生成“/users.980190962”
,这将导致ActionController::UnknownFormat
错误。在某些控制器设置中,您可以修补“/users/980790962”
,但只直接设计修补程序“/users”
。我猜Desive/warden修补程序是谁登录的用户,不需要用户id。因此:
patch user_registration_path, params: { user: {
....
} }
或对于rspec:
put user_registration_path, params