Fix for NameError: uninitialized constant HelpersTest::JSON #703

merged 1 commit into from Apr 7, 2013


None yet
4 participants

viliampucik commented Mar 31, 2013

Fixes the following test error:

NameError: uninitialized constant HelpersTest::JSON

JonRowe commented Apr 1, 2013

Interesting... why hasn't this been needed until now? Is requiring it in the test_helper masking the real problem? I'm guessing sinatra doesn't require 'json' directly to allow you to pick your JSON library, in fact the only place it does require it is in one of the test files test/rabl_test.rb.


rkh commented Apr 2, 2013

Sinatra does not require json as Sinatra doesn't do anything with json.


JonRowe commented Apr 2, 2013

Yes of couse, In my head I some how had it that a templating mode might, or that it'd be used for mime type matching, but that'd never make sense.


patriciomacadden commented Apr 7, 2013

I think this PR should be merged because running the helpers_test standalone (ruby -I lib:test test/helpers_test.rb) produces the error that @viliampucik is describing. This line uses JSON.dump, which is not being required.

This is not failing when running rake test because json is required in test/rabl_test.rb, as @JonRowe said.

It's clear that Sinatra does not require json, but the tests needs to require json.

rkh added a commit that referenced this pull request Apr 7, 2013

Merge pull request #703 from viliampucik/master
Fix for NameError: uninitialized constant HelpersTest::JSON

@rkh rkh merged commit bc60373 into sinatra:master Apr 7, 2013

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment