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
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/tests/test_json_fixtures.rb
poolparty-1.6.5 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.6.4 vendor/gems/json/tests/test_json_fixtures.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/json_pure-1.1.3/tests/test_json_fixtures.rb
merb-core-1.1.0.rc1 spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/tests/test_json_fixtures.rb
poolparty-1.6.3 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.6.2 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.6.1 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.6.0 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.5.0 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.8 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.7 vendor/gems/json/tests/test_json_fixtures.rb
factorylabs-castronaut-0.7.5 vendor/json/tests/test_json_fixtures.rb
poolparty-1.4.6 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.5 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.4 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.3 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.2 vendor/gems/json/tests/test_json_fixtures.rb
poolparty-1.4.1 vendor/gems/json/tests/test_json_fixtures.rb
merb-core-1.1.0.pre spec10/public/core_ext/fixtures/gems/gems/json_pure-1.1.3/tests/test_json_fixtures.rb