を廃止されました機能テストで位置引数を使用した: -私はRSpecの実行時に、私はこの警告を取得してい
DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.
Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }
New keyword style:
get :show, params: { id: 1 }, flash: { notice: "This is a flash message" },
session: nil # Can safely be omitted.
(called from block (4 levels) in <top (required)> at /home/user/organization/fooobarr/spec/controllers/contacts_controller_spec.rb:13)
これは私のコントローラの仕様である: -
require 'rails_helper'
RSpec.describe ContactsController, :type => :controller do
describe "#create" do
it "sends an email when message is valid" do
expect{
post :create, message: attributes_for(:message)
}.to change{ ActionMailer::Base.deliveries.count }.by(1)
end
it "does not send email when message is invalid" do
expect{
post :create, message: {subject: "", name: "",
email:"", content: ""}
}.to change{ ActionMailer::Base.deliveries.count }.by(0)
end
end
end
はライン上でエラーをスローします13,19。
警告が表示されなくなるようにコードを変更する方法がわかりません。
廃止予定メッセージは非常にはっきりしていますが、正確には分かりませんが、新しいスタイルでコードを書き直そうとしましたか? –
@コード例を見ると、それらはすでにキーワード引数を使用しているので、非推奨メッセージの理由はないようです。 – janfoeh
@janfoeh 'message'のようなものはありません。' params、headers、env、xhr'しかないので、彼は試していないと思います。 –