0

这让我困扰了好几天。

test "should check inbox for messages" do
@inbox = create(:inbox)
@user = create(:user)

#user owns inbox
  @inbox.user_id = @user.id
  @inbox.save

  assert_equal @inbox.user_id, @user.id

断言总是失败。

4

1 回答 1

1

试试看:

test "should check inbox for messages" do
    @inbox = create(:inbox, user: create(:user))
    assert_equal @inbox.user_id, @inbox.user.id

否则可能意味着保存记录时出错。检查测试日志:tail -f log/test.log

于 2013-01-13T18:59:27.780 回答