条件付き出力をテストするビュー仕様があります。モックアウトしたユーザーを返すように仕様を取得するにはどうすればよいですか?
ファイルを表示:
.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