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

test failure with rack-test 2.0 #2278

Closed
terceiro opened this issue Aug 21, 2022 · 0 comments · Fixed by #2302
Closed

test failure with rack-test 2.0 #2278

terceiro opened this issue Aug 21, 2022 · 0 comments · Fixed by #2302

Comments

@terceiro
Copy link

If I make this change to Gemfile

diff --git a/Gemfile b/Gemfile
index acc721aa..f0cff687 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,7 +31,7 @@ group :test do
   gem 'maruku'
   gem 'mime-types'
   gem 'rack-jsonp', require: 'rack/jsonp'
-  gem 'rack-test', '~> 1.1.0'
+  gem 'rack-test', '~> 2.0'
   gem 'rspec', '~> 3.11.0'
   gem 'ruby-grape-danger', '~> 0.2.0', require: false
   gem 'simplecov', '~> 0.21.2'

and run the tests (after running bundle), I get the following test failures:

Failures:

  1) Grape::Endpoint#headers includes request headers
     Failure/Error:
       expect(JSON.parse(last_response.body)).to eq(
         'Host' => 'example.org',
         'Cookie' => ''
       )
     
       expected: {"Cookie"=>"", "Host"=>"example.org"}
            got: {"Cookie"=>"", "Host"=>"example.org", "Version"=>"HTTP/1.0"}
     
       (compared using ==)
     
       Diff:
       @@ -1,3 +1,4 @@
        "Cookie" => "",
        "Host" => "example.org",
       +"Version" => "HTTP/1.0",
       
     # ./spec/grape/endpoint_spec.rb:141:in `block (3 levels) in <top (required)>'

  2) Grape::Endpoint#params from body parameters returns a 400 if given an invalid multipart body
     Failure/Error: expect(last_response.body).to eq('empty message body supplied with multipart/form-data; boundary=foobar content-type')
     
       expected: "empty message body supplied with multipart/form-data; boundary=foobar content-type"
            got: "file is invalid"
     
       (compared using ==)
     # ./spec/grape/endpoint_spec.rb:435:in `block (4 levels) in <top (required)>'

Finished in 4.61 seconds (files took 1.81 seconds to load)
2152 examples, 2 failures

Failed examples:

rspec ./spec/grape/endpoint_spec.rb:139 # Grape::Endpoint#headers includes request headers
rspec ./spec/grape/endpoint_spec.rb:426 # Grape::Endpoint#params from body parameters returns a 400 if given an invalid multipart body

It would be nice if these tests could be made to work with rack-test 2.0.

terceiro added a commit to terceiro/grape that referenced this issue Aug 22, 2022
Those two tests endpoint_spec are in the end testing internal details of
rack-test. Change them so that they still test what was intended, but in
a more robust way that does not break on changes on the implementation
details of rack-test.

Fixes: ruby-grape#2278
terceiro added a commit to terceiro/grape that referenced this issue Aug 22, 2022
Those two tests endpoint_spec are in the end testing internal details of
rack-test. Change them so that they still test what was intended, but in
a more robust way that does not break on changes on the implementation
details of rack-test.

Fixes: ruby-grape#2278
@ericproulx ericproulx mentioned this issue Jan 4, 2023
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

Successfully merging a pull request may close this issue.

1 participant