2

I have a /bar/foos path that routes to FoosController. GETting /bar/foos routes to FoosController#index, which works as expected when testing manually.

I inherited some routing tests for this which worked fine with Rails 4.2, but started breaking when updating to Rails 5.0.

For some reason RSpec is creating a id: :foos parameter in expect(get: '/bar/foos') in this spec:

require 'spec_helper'

describe FoosController do
  describe 'routing' do
    it 'get /bar/foos' do
      expect(get: '/bar/foos').to route_to('foos#index')
    end
  end
end

Which yields this error:

The recognized options <{"controller"=>"foos", "action"=>"index", "id"=>"foos"}> 
did not match <{"controller"=>"foos", "action"=>"index"}>, difference:.
--- expected
+++ actual
@@ -1 +1 @@
-{"controller"=>"foos", "action"=>"index"}
+{"controller"=>"foos", "action"=>"index", "id"=>"foos"}

I am using Rails 5.0.2 and rspec 3.6.0.beta2.

Leo Brito
  • 2,053
  • 13
  • 20

0 Answers0