Sha256: bb1806fa33995fea86ba43debe8be2a6e8e0e1940e13116f5e33843e27caa9ec

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 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 {
          Yajl::Stream.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 {
          Yajl::Stream.parse(StringIO.new(source))
        }.should_not raise_error(Yajl::ParseError)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
brianmario-yajl-ruby-0.4.0 specs/fixtures_spec.rb
brianmario-yajl-ruby-0.4.1 specs/fixtures_spec.rb
brianmario-yajl-ruby-0.4.2 specs/fixtures_spec.rb
brianmario-yajl-ruby-0.4.3 spec/fixtures_spec.rb
brianmario-yajl-ruby-0.4.4 spec/fixtures_spec.rb
brianmario-yajl-ruby-0.4.5 spec/fixtures_spec.rb
brianmario-yajl-ruby-0.4.6 spec/fixtures_spec.rb