rails 3.0.2 + jasmine 1.0.1.1 + json_pure == dll_hell.rb

November 23, 2010 Ken Mayer

The 3.0.2 update to rails made a change in active support that creates an interference pattern failure in the jasmine-gem. Not jasmine, itself, mind you, just the standalone server that runs the jasmine tests, and not the server, but just the report runner. Thus, your tests are all green, but the jasmine suite fails anyway. You might see this error:

undefined method `merge' for #<JSON::Pure::Generator::State:0x102181890> (NoMethodError)

The selenium driver inside the jasmine gem is loadingjson_pureunless it can find an already loaded JSON class. json_pure was hacked by rails for other reasons, but it breaks JSON.generate. Madness ensues.

To fix this, you need to use something other than json_pure, at least in your test suite. The fix, fortunately, is pretty simple. Add the following line to your Gemfile

gem "json", "1.4.6"

This will load the json gem built with native extensions. The version number is not necessary to fix this problem, but we try to lock down versions as a standard practice.

This was maddeningly painful to pinpoint. I’m not sure if there’s a long term solution to the problem either. You need a JSON library, but so do many others. Monkey patching the class seems really handy, but is prone to break behaviors.

About the Author

Biography

More Content by Ken Mayer
Previous
Maintainable State Machines Part 1 – scopes and predicate methods
Maintainable State Machines Part 1 – scopes and predicate methods

In this post I'll point out a few ways to write maintainable scopes and predicate methods on ActiveRecord o...

Next
New Tech Talk: Qualitative Research – Tips for Getting Started Talking to Users
New Tech Talk: Qualitative Research – Tips for Getting Started Talking to Users

Talking to users is a good idea but where to begin? Qualitative Research expert Laura Klein gets you starte...

Enter curious. Exit smarter.

Register Now