我正在構建一個測試應用程序,允許用戶創建/刪除帖子。我在我的銷燬行爲中遇到了一個錯誤,我發現它很難調試。下面是我的測試: describe '#destroy' do
context 'existing post' do
let (:post) { FactoryGirl.create(:post) }
it 'removes post from table'
鑑於ActiveRecord模型與架構, create_table "foos", id: :serial, force: :cascade do |t|
t.date "date"
t.time "time"
# ...
和FactoryGirl一個Foo工廠, FactoryGirl.define do
factory :foo do
date D
嘗試與FactoryGirl.create(:place)創建地方實例,但得到了以下錯誤: Failure/Error: FactoryGirl.create(:place)
ActiveRecord::StatementInvalid:
PG::NotNullViolation: ERROR: null value in column "town_city" violates not
試圖爲嵌套區域記錄創建工廠。爲此,我使用ancestry寶石。地區是地方關聯實體 地點工廠: factory :place, traits: [:pageable] do
...
association :region, factory: :nested_regions
end
地區工廠: factory :region do
level 'area'