我有一个视图规范,我正在测试条件输出。如何让规范返回我模拟出来的用户?
查看文件:
.content
- if @current_user.is_welcome == true
Welcome to the site
查看规格:
before(:each) do
@user = mock_model(User)
@user.stub!(:is_welcome).and_return(true)
view.stub(:current_user).and_return(@user)
end
it "show content" do
#assign(:current_user, stub_model(User, dismiss_intro: true))
render
rendered.should have_content("Welcome to the site")
end
运行规范返回undefined method is_welcome for nil:NilClass