Sha256: 1ba935c12a2e12acc0f1c45dffc2c47425bc3f478ce59a91745136a1b7ec0e9c

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
brianmario-yajl-ruby-0.5.3 spec/parsing/fixtures_spec.rb
brianmario-yajl-ruby-0.5.4 spec/parsing/fixtures_spec.rb
brianmario-yajl-ruby-0.5.5 spec/parsing/fixtures_spec.rb
brianmario-yajl-ruby-0.5.6 spec/parsing/fixtures_spec.rb
yajl-ruby-0.5.5 spec/parsing/fixtures_spec.rb
yajl-ruby-0.5.6 spec/parsing/fixtures_spec.rb