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

Compatibility with grape-entity > 0.5.0 #1350

Closed
przbadu opened this issue Apr 6, 2016 · 7 comments
Closed

Compatibility with grape-entity > 0.5.0 #1350

przbadu opened this issue Apr 6, 2016 · 7 comments

Comments

@przbadu
Copy link

przbadu commented Apr 6, 2016

I forked and clone grape and run test cases on master branch and I got these three failing specs:

Failures:

  1) Grape::API http_codes is used as presenter
     Failure/Error: expect(last_response.body).to eql({ code: 408, static: 'some static text' }.to_json)

       expected: "{\"code\":408,\"static\":\"some static text\"}"
            got: "{:code=>408, :static=>\"some static text\"}"

       (compared using eql?)
     # ./spec/grape/api_spec.rb:2045:in `block (3 levels) in <top (required)>'

  2) Grape::API http_codes presented with
     Failure/Error: expect(last_response.body).to eql({ code: 408, static: 'some static text' }.to_json)

       expected: "{\"code\":408,\"static\":\"some static text\"}"
            got: "{:code=>408, :static=>\"some static text\"}"

       (compared using eql?)
     # ./spec/grape/api_spec.rb:2056:in `block (3 levels) in <top (required)>'

  3) Grape::Middleware::Error with http code presents an error message
     Failure/Error: expect(last_response.body).to eq({ code: 200, static: 'static text' }.to_json)

       expected: "{\"code\":200,\"static\":\"static text\"}"
            got: "{:code=>200, :static=>\"static text\"}"

       (compared using ==)
     # ./spec/grape/middleware/error_spec.rb:75:in `block (3 levels) in <top (required)>'

Finished in 8.14 seconds (files took 4.18 seconds to load)

We are expecting json response but are actually getting String of Hash. May be all of them are related with presenter and I also try to fixed it, but couldn't figure out the solution.

@przbadu
Copy link
Author

przbadu commented Apr 6, 2016

I am on ruby 2.2.3

@dblock
Copy link
Member

dblock commented Apr 6, 2016

I can confirm that. Looks like it was introduced by grape-entity 0.5.1, which is used in specs. It work with 0.5.0. I don't see anything immediately obvious in https://github.com/ruby-grape/grape-entity/blob/master/CHANGELOG.md, opened ruby-grape/grape-entity#213. Needs to be tracked down.

@dblock
Copy link
Member

dblock commented Apr 6, 2016

Introduced by a regression in ruby-grape/grape-entity#204.

dblock added a commit to dblock/grape that referenced this issue Apr 6, 2016
przbadu added a commit to przbadu/grape that referenced this issue Apr 6, 2016
przbadu added a commit to przbadu/grape that referenced this issue Apr 6, 2016
dblock added a commit that referenced this issue Apr 6, 2016
Workaround for #1350, lock grape-entity at 0.5.0.
@dblock dblock changed the title Failing spec in master branch Compatibility with grape-entity > 0.5.0 Apr 24, 2016
@wleeper
Copy link

wleeper commented May 13, 2016

This also affects the generation of error messages that use an Entity model for generating the output. This is due to the fact that it is expecting the present method to generate a hash but now with 0.5.1 it generates an object.

You end up with your entity generated output being wrapped with in "error": "entity model"

@sagebomb
Copy link

sagebomb commented Jul 4, 2016

Hi guys. Please take a look: ruby-grape/grape-entity#232
Grape specs are green now.

@sagebomb
Copy link

@wleeper @przbadu can you check grape master specs with last grape-entity? Everything works fine for me. I think the issue is not actual anymore.

@dblock
Copy link
Member

dblock commented Jan 14, 2017

Closing, this is fixed.

@dblock dblock closed this as completed Jan 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants