我在Rails的安裝製作和法克爾4項目問題與法克爾寶石
我創建了一個fabrarication對象:
Fabricator(:course) do
title { Faker::Lorem.words(5) }
description { Faker::Lorem.paragraph(2) }
end
我打電話我courses_controller_spec.rb測試中法克爾對象:
require 'spec_helper'
describe CoursesController do
describe "GET #show" do
it "set @course" do
course = Fabricate(:course)
get :show, id: course.id
expect(assigns(:course)).to eq(course)
end
it "renders the show template"
end
end
但由於某些原因,測試failes第6行:
course = Fabricate(:course)
的錯誤信息是:
Failure/Error: course = Fabricate(:course)
TypeError:
can't cast Array to string
不知道爲什麼,這是失敗的。有沒有人與Faker經歷過相同的錯誤信息?
工作,非常感謝depa – Toontje
非常感謝。我在Rails應用程序中遇到了同樣的錯誤。 – Tintin81
在下面添加了另一個解決方案。 – NoobException