0
我有这样的测试:方括号
def test_should_only_list_promoted_on_index
get :index
assert_equal stories(:promoted), assigns(:stories)
end
其失败消息:
<#<Story id: 3, name: "What is a Debugger?", link: "http://en.wikipedia.org/wiki/Debugger", created_at: "2011-03-25 20:57:04", updated_at: "2011-03-25 20:57:04", user_id: 2, votes_count: 5, description: nil>> expected but was
<[#<Story id: 3, name: "What is a Debugger?", link: "http://en.wikipedia.org/wiki/Debugger", created_at: "2011-03-25 20:57:04", updated_at: "2011-03-25 20:57:04", user_id: 2, votes_count: 5, description: nil>]>.
但是如果我把方括号围绕
“(:提拔)的故事”参数
def test_should_only_list_promoted_on_index
get :index
assert_equal [stories(:promoted)], assigns(:stories)
end
测试成功。为什么是这样?
我使用的Rails 2.3.9和Ruby 1.9.2