0
我有以下工廠:錯誤在RSpec的測試與我廠
FactoryGirl.define do
factory :category do
name "Example category"
user_id 1
end
end
這是我的測試:
describe "POST #create" do
context "signed in" do
before(:each) do
sign_in :user, user
end
context "with valid attributes" do
it "saves the new category in the database" do
expect{
post :create, FactoryGirl.attributes_for(:category)
}.to change(Category, :count).by(1)
end
it "redirects to category #index"
end
context "with invalid attributes" do
it "does not save the new category in the database"
it "re-renders the :new template"
it "provides errors"
end
end
context "not signed in" do
it "blocks access (somehow)"
end
end
但是,我發現了以下錯誤,當我運行我的測試:
3) CategoriesController POST #create signed in with valid attributes saves the new category in the database
Failure/Error: post :create, FactoryGirl.attributes_for(:category)
ActionController::ParameterMissing:
param not found: category
我已經設法使用工廠以前,它在我的規格/型號/測試中工作正常。有什麼我在這裏做錯了嗎?我看不到工廠有任何問題。我有點失去:(