0
儘管知道功能在應用程序中有效,但我仍有失敗的測試。我的直覺說,我應該嘗試保存我創建的東西,但我不確定如何在assert_difference塊中執行此操作,因爲它看起來不像新的thing
已分配給我可以.save
的變量。感謝您提供的任何建議。儘管功能在應用程序中運行,但創建項目測試仍然失敗
測試:
test "should create thing" do
assert_difference('thing.count') do
post :create, thing: { thing_type_id: @thing.thing_type_id, name: @thing.name}
end
輸出:
1) Failure:
test_should_create_thing(thingsControllerTest) [C:/../thing_controller_test.rb:20]:
"thing.count" didn't change by 1.
<3> expected but was
<2>.
謝謝你解釋的細節。 – 2013-05-06 16:33:45