【发布时间】:2014-10-15 09:53:33
【问题描述】:
我正在使用工厂女孩来创建我的对象。我想知道为什么我必须执行以下操作:
RSpec.describe V1::SlotsController, type: :controller do
let(:valid_slot) { create(:slot) }
let(:valid_attributes) { attributes_for(:slot) }
describe "DELETE destroy" do
it "destroys the requested slot" do
slot = Slot.create! valid_attributes # not working without this line
expect {
delete :destroy, { id: slot.id }
}.to change(Slot, :count).by(-1)
end
end
end
如果我不覆盖slot,只使用factory_girl创建的那个,测试不会通过。为什么会这样?
【问题讨论】:
标签: ruby-on-rails-4 rspec-rails rspec3