1
我有作用的控制器:Rails的RSpec的測試wheter控制器動作定義實例變量
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