Reputation: 741
How can I test this in rails: A student goes to a list of their groups, and when they click the link, it brings them to that group page.
I have the gist of it down, but how can I test that it went to a page? I was thinking something along the lines of:
expect(page).to eq()
but then I am not sure what to do from there. I don't want to just expect the page to have the name of the group, because that that would be on the overall list and the page the link would bring them to. Any advice?
Upvotes: 0
Views: 35
Reputation: 1170
You're looking for the redirect_to()
method. So an example would be:
require 'spec_helper'
describe FoobarController do
describe "GET foo" do
it "redirects to bar" do
get :foo
expect(response).to redirect_to(bar_path)
end
end
end
Upvotes: 1