hashie/hashie

I got in dev a failing test from master, how to properly setup?

Closed this issue · 5 comments

Running tests from master branch, latest commit #a30327a I got a failing test:

Failures:

  1) DashTestDefaultProc to_json behaves correctly with default proc
     Failure/Error: to_hash.to_json(*args)
     
     NoMethodError:
       undefined method `to_json' for {:fields=>[]}:Hash
       Did you mean?  to_s
     # ./lib/hashie/hash.rb:43:in `to_json'
     # ./spec/hashie/dash_spec.rb:61:in `block (2 levels) in <top (required)>'

Finished in 0.18124 seconds (files took 0.31668 seconds to load)
673 examples, 1 failure

Failed examples:

rspec ./spec/hashie/dash_spec.rb:59 # DashTestDefaultProc to_json behaves correctly with default proc

same for ruby 2.5, 2.6 and 2.7.

But at Travis it is OK -- build passing . How I do configure my env to properly works? I should be using a specific ruby version?

This doesn't seem right. Looks like the json gem is not properly required, this would happen if we were missing require 'json'. We don't actually do that anywhere explicitly.

I assume you ran bundle install first and it got everything, including json, which is a dependency.

~/source/hashie/dblock (master)$ bundle | grep json
Using json 2.2.0

Next, what's bundle show json

~/source/hashie/dblock (master)$ bundle info json
  * json (2.2.0)
	Summary: JSON Implementation for Ruby
	Homepage: http://flori.github.com/json
	Path: /Users/dblock/.rvm/gems/ruby-2.7.1/gems/json-2.2.0

Finally, any difference running bundle exec rspec spec vs. rspec spec?

Yes, I did run bundle through ./bin/setup, using fresh and clean gemsets.

ruby 2.5.7

JSON installed, but version 2.3.1

➜  hashie git:(master) bundle info json
  * json (2.3.1)
	Summary: JSON Implementation for Ruby
	Homepage: http://flori.github.com/json
	Path: ~/.rvm/gems/ruby-2.5.7@hashie-dev/gems/json-2.3.1

there is no diff between bundle exec rspec spec and rspec spec

ruby 2.6.5

  * json (2.3.1)
	Summary: JSON Implementation for Ruby
	Homepage: http://flori.github.com/json
	Path: ~/.rvm/gems/ruby-2.6.5@hashie-dev/gems/json-2.3.1

there is no diff between bundle exec rspec spec and rspec spec

ruby 2.7.1

  * json (2.3.1)
	Summary: JSON Implementation for Ruby
	Homepage: http://flori.github.com/json
	Path: ~/.rvm/gems/ruby-2.7.1@hashie-dev/gems/json-2.3.1

there is no diff between bundle exec rspec spec and rspec spec

Now forcing json to 2.2.0

ruby 2.5.7

➜  hashie git:(master) ✗ bundle info json  
  * json (2.2.0)

same result as above

ruby 2.6.5

➜  hashie git:(master) ✗ bundle info json      
  * json (2.2.0)

same result as above

ruby 2.7.1

➜  hashie git:(master) ✗ bundle info json      
  * json (2.2.0)

same result as above

Add require 'json' into spec_helper.rb. Works?

it works.

I'm still curious to know why CI works and my env doesn't -- going to investigate later.

I bet this is actually a bug and all of the rest of us have a globally available json gem or something and it doesn't work with a clean gemset. Also what's your OS @gnomex?