Sha256: a253fd919abc6542e2f27f5d92de67e0a0c190653e6dd9c2538c4890cc774242

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 Bytes

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')

describe "Parsing JSON Fixtures" do
  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
  
  FAILED.each do |name, source|
    it "should not be able to parse #{File.basename(name)}" do
        lambda {
          parser = Yajl::Parser.new
          parser.parse(StringIO.new(source))
        }.should raise_error(Yajl::ParseError)
    end
  end
  
  PASSED.each do |name, source|
    it "should be able to parse #{File.basename(name)}" do
        lambda {
          parser = Yajl::Parser.new
          parser.parse(StringIO.new(source))
        }.should_not raise_error(Yajl::ParseError)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brianmario-yajl-ruby-0.5.0 spec/parsing/fixtures_spec.rb
brianmario-yajl-ruby-0.5.1 spec/parsing/fixtures_spec.rb
brianmario-yajl-ruby-0.5.2 spec/parsing/fixtures_spec.rb