I have a controller test, where I want to do a GET on a page. Our URL's are complex, and need to be correct (duh, but we allow some slop, but that causes a redirect which I want to avoid). Anyway, in my controller test I do a get to the URL that is produced by a helper method which calls a named route URL helper. This is not working, and I'm wondering why/what I'm messing up. Here's the line in the spec code that starts things off (@widget is a real ActiveRecord object): get @controller.widget_path_for_seo(@widget)
The widget_path_for_seo method is defined in our ApplicationController. It digs some info out of the widget instance that then get passed to the named route URL helper method, so it looks like this: def widget_path_for_seo(widget) location = seo_name_for_url widget.location.name building = seo_name_for_url(building_name_for_seo_url(widget.building), true) + "-widgets" widget_id = seo_name_for_url(widget.name) + "-" + widget.id.to_s seo_widget_path(:location => location, : building => building, :id => widget_id) end It's the "seo_widget_path" named route helper method that is failing. I've checked that all values going into it are valid, but the error I get is in ActionController::Base.url_for, where it's looking at the options hash of values that are passed in, and doing this: @url.rewrite(rewrite_options(options)) It compalins that @url is nil. I'm wondering if this is due to being run under the test environment or what I'm missing/not realizing, etc. What's strange is that some of the restful resource route url helpers work fine. Can anyone clue me in? -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users