私のコントローラーでは、ユーザーが新しい投稿を作成すると、新しく作成された投稿を含むページにリダイレクトされます。このリダイレクトをカバーするためにrspecでテストを作成したいのですが、問題が発生しています。具体的には、refirst_to引数に何を書くべきか知りたいです。以下はコントローラーコードです。
def create
@micropost = Micropost.new(params[:micropost])
respond_to do |format|
if @micropost.save
format.html {redirect_to @micropost}
else
format.html {render action: 'edit'}
end
end
end
これがrspecテストです...
before do
@params = FactoryGirl.build(:micropost)
end
it "redirects to index" do
#clearly @params.id doesn't work. its telling me instead of a redirect im getting a
#200
#response.should redirect_to(@params.id)
end