正しく設定するための作成アクションを取得しようとしています。Rspec ruby rails
私はエラーを取得しておいてください。ここではArgumentError: Unknown keyword: topic
はテストです:ここでは
require 'rails_helper'
RSpec.describe TopicsController, type: :controller do
let(:my_topic) { Topic.create!(name: RandomData.random_sentence, description: RandomData.random_paragraph)}
describe "POST create" do
it "increases the number of topics by 1" do
expect{ post :create, {topic: {name: RandomData.random_sentence, description: RandomData.random_paragraph}}}.to change(Topic,:count).by(1)
end
it "assigns Topic.last to @topic" do
post :create, { topic: {name: RandomData.random_sentence, description: RandomData.random_paragraph}}
expect(assigns(:topic)).to eq Topic.last
end
it "redirects to the new topic" do
post :create, {topic: {name: RandomData.random_sentence, description: RandomData.random_paragraph}}
expect(response).to redirect_to Topic.last
end
end
はコントローラです:
def create
@topic = Topic.new
@topic.name = params[:topic][:name]
@topic.description = params[:topic][:description]
@topic.public = params[:topic][:public]
if @topic.save
redirect_to @topic, notice: "Topic was saved successfully."
else
flash.now[:alert] = "Error creating topic. Please try again"
render :new
end
end
私は私は何を把握しようとしていますこのエラーを引き起こしている行方不明です。何時間もそれを見つめていて、何度も何度も編集しようとしました。私はそれを理解することはできません。私が取り組んできたプロジェクトの残りの部分は大丈夫でしたが、私はなぜ単語のトピックをうまく変換できないのか分かりません。見ていただきありがとうございます。
ありがとうございます。 –