Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

merged 1 commit into from

4 participants


Fixes the following test error:

NameError: uninitialized constant HelpersTest::JSON

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

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


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.


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 rkh merged commit bc60373 into sinatra:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 0 deletions.
  1. +1 −0  test/helpers_test.rb
1  test/helpers_test.rb
@@ -1,5 +1,6 @@
require File.expand_path('../helper', __FILE__)
require 'date'
+require 'json'
class HelpersTest < Test::Unit::TestCase
def test_default
Something went wrong with that request. Please try again.