0

I'm using rspec-rails 2.13.1 and Capybara 1.1.4. Whenever I try to get root_path or get page_path("anything"), the spec throws ActionController::RoutingError:No route matches [GET] "/"

I can run visit 'http://example.dev no problem, but I'd much rather use URL helpers. Any idea why this might not be working?

2
  • Do you define root in the routes, like root :to => "home#index"
    – Henry
    Jun 30, 2013 at 5:00
  • Yes, and Billy Chan's answer below helped me out Jul 1, 2013 at 6:59

1 Answer 1

1

You can still use named urls in Capybara like

visit root_path

But you can't use get, post in Capybara, which are better for controller tests. Also, they are considered low level in Capybara's integration tests.

2
  • Thanks, sometimes it's difficult to know where to draw the line in integration tests vs controller tests. I suppose the response.status should be(200) sort of tests should be in the controller specs as well? Jul 1, 2013 at 6:58
  • 1
    @professormeowingtons, yes, what you said belongs to controller specs. The rule of thumb to differentiate them is, integration test will mimic what human being could do while controller tests are for machine. For example, human being can't POST, PUT, but machine can.
    – Billy Chan
    Jul 1, 2013 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.