I am writing a view spec for a view (surprise, surprise) that has call to a path helper in the form of…
edit_company_url(:format => 'json')
When rendered in the browser (on an html rendering of the same company#edit action), this works fine since the params contain the appropriate :id, and rails magic is able to discern the correct url. However, when trying to write a view spec for this template, I get an routing error due to the lack of a company ID. It still fails even when I setup params within the spec. If I rewrite the helper call to…
edit_company_url(@company, :format => 'json')
then the test works fine. I’ll probably end up leaving it like that, as it’s more explicit/readable anyway. But Im curious if there’s an appropriate way to setup params, etc, in the view spec to make this helper work as originally written.