LoadError: cannot load such file -- [{ 'key':'value' }] #27

Closed
halissonvit opened this Issue Apr 26, 2012 · 10 comments

Comments

Projects
None yet
3 participants

I'm trying to use json_spec with cucumber, but using the step:

  Then the JSON should be:
  """
  {
    'key':'value'
  }
  """

The error is in the helpers.rb file, in the method:

  def multi_json_load(json)
    MultiJson.respond_to?(:load) ? MultiJson.load(json) : MultiJson.decode(json)
  end

Using just MultiJson.decode(json) works fine.

Sorry for my bad english x;

I'm using Ruby 1.9.3 and Rails 3.2

Contributor

laserlemon commented Apr 26, 2012

Thanks for the report, Halisson. What version of MultiJson are you using?

gem list multi_json
*** LOCAL GEMS ***

  multi_json (1.3.2, 1.2.0)
Contributor

laserlemon commented Apr 27, 2012

Hmm, could you please test under each version in isolation?

Contributor

laserlemon commented Apr 27, 2012

If you have a Gemfile.lock, could you please throw that into a Gist and link to it here?

sferik commented Apr 27, 2012

It's best not to use MultiJson.respond_to?(:load), since Kernel (which defines a load method) gets mixed in to Object. I'd recommend using MultiJson.adapter as a proxy to detect MultiJson.load, since those two methods were added at the same time. See https://github.com/rails/rails/pull/5896/files as an example.

Contributor

laserlemon commented Apr 27, 2012

Thanks @sferik. @halissonvit, I can't reproduce the problem locally on either version of multi_json. Please provide your Gemfile.lock when you're able and maybe I can track this down. I'd like to confirm that Erik's suggestion really does solve your problem. Thanks.

My Gemfile.lock
https://gist.github.com/2554748

Thank's for the fast response

sferik commented Apr 30, 2012

There's no longer a need to feature-detect in the latest version of MultiJson (1.3.4). decode is an alias of load that no longer prints deprecation warnings.

Contributor

laserlemon commented Apr 30, 2012

New version released, moving back to decode until the next major version of multi_json ships.

@laserlemon laserlemon closed this Apr 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment