GET an url or path, provided as string, in an rspec test

Viewed 21390

For a controller that determines the behaviour of a sidebar, I need to call several urls; the sidebar will change (a.o) based on the page on which it appears.

describe SidebarController do
  before(:each) do
    @sidebar = SidebarController.new
  end
  it 'should return :jobseekers for root_path' do
    get(root_url)
    @sidebar.section(root_path).should eq :jobseekers
  end
end

This, however, fails with ActionController::RoutingError: No route matches {:controller=>"sidebar", :action=>"http://test.host/"}

Can I get an url or path as string? Is there a smarter way to set the request. data, rather then GETting it?

2 Answers
Related