Sha256: c58ff57ed43d605d6e2f70dd895e077462eb6004b9ded864a663d50150e09b17

Contents?: true

Size: 776 Bytes

Versions: 103

Compression:

Stored size: 776 Bytes

Contents

#!/usr/bin/env ruby

require 'test/unit'
require 'json'

class TC_JSONFixtures < Test::Unit::TestCase
  def setup
    $KCODE = 'UTF8'
    fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
    passed, failed = Dir[fixtures].partition { |f| f['pass'] }
    @passed = passed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
    @failed = failed.inject([]) { |a, f| a << [ f, File.read(f) ] }.sort
  end

  def test_passing
    for name, source in @passed
      assert JSON.parse(source),
        "Did not pass for fixture '#{name}'"
    end
  end

  def test_failing
    for name, source in @failed
      assert_raises(JSON::ParserError, JSON::NestingError,
        "Did not fail for fixture '#{name}'") do
        JSON.parse(source)
      end
    end
  end
end

Version data entries

103 entries across 97 versions & 16 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.0 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.1 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.10 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.11 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.12 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.13 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.14 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.15 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.16 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.17 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.2 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.3 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.4 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.5 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.6 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.7 vendor/gems/json/tests/test_json_fixtures.rb
auser-poolparty-1.3.8 vendor/gems/json/tests/test_json_fixtures.rb
benschwarz-smoke-0.5.0 vendor/json-1.1.3/tests/test_json_fixtures.rb
benschwarz-smoke-0.5.1 vendor/json-1.1.3/tests/test_json_fixtures.rb