Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request specs fail after upgrading to Rack 3 #2814

Open
cjamison opened this issue Nov 23, 2024 · 4 comments
Open

Request specs fail after upgrading to Rack 3 #2814

cjamison opened this issue Nov 23, 2024 · 4 comments

Comments

@cjamison
Copy link

We have a number of request specs for our API and after upgrading Rack from 2.x to 3.x, they all started failing with:

     Failure/Error: get "/api/v1/products/1", headers: @headers
     
     NoMethodError:
       undefined method `read' for nil:NilClass

The way to resolve these errors is to convert the get request to

get "/api/v1/products/1", headers: @headers, env: { 'rack.input' => StringIO.new }

However, it seems very verbose to add this to each request. Am I missing an easier / better way to avoid this error?

This is on rspec-rails 7.1.0 and rspec-core 3.13.2.

@JonRowe
Copy link
Member

JonRowe commented Nov 24, 2024

👋 We don't include any behaviour for this ourselves and rely on the upstream Rails / rack-test helpers, is Rack 3 supported by Rails 8? I think 7 is still pinned to 2.x isn't it?

@cjamison
Copy link
Author

No, Rails 7 is not pinned to 2.x. At least 7.1 is not which is what we are using.

I see what happened on our end. We have another gem using/requiring Sinatra and at least Sinatra 4.1.1 is requiring rack >= 3.0.0. So, that is what caused our jump. I will see if we want to continue as things are or downgrade Sinatra to something not requiring rack 3.

@JonRowe
Copy link
Member

JonRowe commented Nov 25, 2024

My mistake 7.0 is, but not anything later, what version of Rack are you on? It seems like 3.1 made "rack.input" fully optional?

@cjamison
Copy link
Author

Bundle installed rack 3.1.8. In spite of "rack.input" being optional in this version, it still gave me the error message without me adding it into the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants