Closed jobwat closed 4 years ago
Are you seeing that issue in a controller spec?
I ran into the same problem and found that it was due to versioncake's switch from Railties to Rack Middleware between v2.x and v3.x. Rails functional tests (RSpec controller tests) are not Rack middleware aware and are unable to initialize versioncake as they had in v2.x.
Looks like the solutions are to either stub request_version
as suggested in the README or convert the specs to Rails integration tests (RSpec request specs) to exercise the entire stack, including the versioncake middleware
Thank you for your comment!
I don't want to stub the request_version
as I want to test a specific version is properly served from a header... but from my understanding, the middleware needs to be there to take the stubbed version anyway! no?
As for Rails integration tests
, I believe that's what I'm using.
Thanks again for replying, it put my head back into it :)
Are you sure you're using Rails integration tests and not just controller specs?
Thanks for that insistence, I now understood the difference and indeed my tests are controller specs...
I haven't had time to get back on that project yet, but will most likely move my specs to an integration test and mock the version in the controller specs, it all makes sense now.
Thanks
Thanks for following up @jobwat, let us know if you need any help getting setup again. 🙌
I'm upgrading an old application, the current stable is at versioncake 2.5.0, with ruby 2.3 & rails 4.2.11.1.
I can't manage to get versioncake to 3.x, the specs fail due to empty responses because of the versioned views not being loaded. But the live application is all working fine!
To my surprise, when inspecting from the controller, I can see the Rack Middleware isn't present for a rspec test.
From a development browser request:
From a spec:
I don't quite know how to debug further, hope someone can help