jsmestad / jsonapi-consumer

Client framework for consuming JSONAPI services in Ruby
https://github.com/jsmestad/jsonapi-consumer
Apache License 2.0
94 stars 18 forks source link

undefined method `parser' for Parser:Module after bumping parser dependency to 2.6 #27

Open michaltrzcinka opened 5 years ago

michaltrzcinka commented 5 years ago

Describe the bug After upgrading parser dependency from 2.5.1.2 to 2.6.0.0 (because of Rubocop upgrade), I started to see the following errors from my test suite:

  Failure/Error: klass.parser.parse(klass, connection.run(type, path, params, headers))

     NoMethodError:
       undefined method `parser' for Parser:Module
       Did you mean?  parent
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:11:in `block (2 levels) in initialize'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:10:in `map'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:10:in `block in initialize'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:8:in `each'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:8:in `inject'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/included_data.rb:8:in `initialize'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/parsers/parser.rb:108:in `new'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/parsers/parser.rb:108:in `handle_included'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/parsers/parser.rb:18:in `block in parse'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/parsers/parser.rb:8:in `tap'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/parsers/parser.rb:8:in `parse'
     # ./app/resources/custom_requestor.rb:22:in `request'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/query/requestor.rb:28:in `get'
     # /Users/michal/.rvm/gems/ruby-2.5.3/bundler/gems/jsonapi-consumer-7016fe3eb5ee/lib/jsonapi/consumer/query/builder.rb:102:in `find'
     # ./app/controllers/stores_controller.rb:192:in `set_store'

To Reproduce Steps to reproduce the behavior:

  1. Upgrade parser dependency
  2. Run any code which uses included_data.rb

Expected behavior No error should occur.

Screenshots N/A

Desktop (please complete the following information): N/A

Smartphone (please complete the following information): N/A

Additional context

My guess is that JSON-API Consumer is incompatible with the new version of parser gem, which came out yesterday.

michaltrzcinka commented 5 years ago

Actually, the problem persists even if I fix the parser dependency to 2.5.1.2. So the problem seems result from Rubocop upgrade - from 0.58.2 to 0.60.

jsmestad commented 5 years ago

@michaltrzcinka I am in the middle of moving overseas. Could you take a stab at a fix? If you cannot, I should have time to get to this in a few weeks.