我有一个带动作的控制器:
def new
@team = Team.new
@team.team_links.build
end
我想用 rspec 测试这个动作。(我知道它可以工作,因为它可以在应用程序中正常工作,但我的规范失败了。)这是我的规范:
it "returns new team with built in team_link" do
get 'new'
team = assigns(:team)
team.should be_new_record
team.team_links.should_not be_empty # HERE IS WHERE IT FAILS
end
这是错误消息:
1) TeamsController GET new returns @team and builds one team_link
Failure/Error: team.team_links.should_not be_empty
expected empty? to return false, got true