Search code examples
ruby-on-rails-3automated-testsruby-on-rails-plugins

Rails 3 - How can I get rid of "test.host"?


I recently installed a plugin called Gretel to take care of breadcrumbs for me. It seems to be working great, except that it appears to be breaking some of my specs with the following error:

 Failure/Error: response.should redirect_to @course
 Expected response to be a redirect to </courses/904> but was a redirect to
 <http://test.host/courses/904>

What can I do to get rid of this error? The path seems totally correct, with the exception of that pesky test.host thing.


Solution

  • You are probably testing against my_model_url instead of my_model_path

    The former does a full URI - including the host. The latter is a relative path without the host.

    Go have a check in your controller and see if it uses _path or _url - and use the same one in your test-cases.