アプリで機能が動作することを知っていても、失敗するテストがあります。thing
私の本能は、私が作成したものを保存しようとするべきだと言っていますが、 assert_difference ブロックでこれを行う方法がわかりません.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>.