Question

I am trying to port my application from Rails 3.2.x to Rails 4.0.4. All the gems have been made compatible and I am in the phase of fixing failing tests.

I have this weird test failure.

My routes.rb

resources :my_reports, only: [:index] do
  collection do
    get "/report/:filename", to: :show, prefix: "pri/excl/rep", as: :show
  end
end

My spec which has been passing in Rails 3.2.x and now failing after update to 4.0.4

describe MyReportsController do
  describe "#show" do
    def make_request
      get :show, prefix: 'some/place', filename: 'foo', format: 'doc'
    end

    it "makes a simple request" do
      make_request
    end
  end
end

I am getting the following error

Failure/Error: get :show, prefix: 'some/place', filename: 'foo', format: 'doc'
     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"my_reports", 
        :filename=>"foo", :format=>"doc", :prefix=>"some/place"}

I am stuck at this point, hints are welcome. I am using rspec and rspec-rails versions 2.14.1.

Was it helpful?

Solution

Passing a dummy :id in the test fixed the issue for me although I would not like it, tests pass.

get :show, id: "", prefix: 'some/place', filename: 'foo', format: 'doc'

Refer to state of rails releases here.

OTHER TIPS

You're describing the show method but your route is only available for the index one. Maybe it's a beginning of solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top