Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

4 participants

@viliampucik

Fixes the following test error:

test_should_not_reset_the_content_type_to_html_for_error_handlers_0(HelpersTest::TestError):
NameError: uninitialized constant HelpersTest::JSON
@JonRowe

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
Owner
rkh commented

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

@JonRowe

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

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
View
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.