Rails rspec test wheter controller action define instance variable -
i have controller action:
def new @team = team.new @team.team_links.build end
and want test action rspec. (i know works, because works should in application, specs failing.) here spec:
it "returns new team built in team_link" 'new' team = assigns(:team) team.should be_new_record team.team_links.should_not be_empty # here fails end
here error message:
1) teamscontroller new returns @team , builds 1 team_link failure/error: team.team_links.should_not be_empty expected empty? return false, got true
@team.team_links.build
neither persist record nor instance variable, effect of line disappeared in view context.
you need assign instance variable testable in view:
# controller @team_link = @team.team_link.build # rspec assigns(:team_link).should_not be_empty
Comments
Post a Comment