Sha256: 5b1ffef0b6ee0232502fc08f03db5a3e780b83bf41c06de42ec283a75164726b

Contents?: true

Size: 1.21 KB

Versions: 13

Compression:

Stored size: 1.21 KB

Contents

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
        expect {
          Yajl::Parser.parse(StringIO.new(source))
        }.to 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
        expect {
          Yajl::Parser.parse(source)
        }.to raise_error(Yajl::ParseError)
    end
  end

  PASSED.each do |name, source|
    it "should be able to parse #{File.basename(name)} as an IO" do
        expect {
          Yajl::Parser.parse(StringIO.new(source))
        }.not_to raise_error
    end
  end

  PASSED.each do |name, source|
    it "should be able to parse #{File.basename(name)} as a string" do
        expect {
          Yajl::Parser.parse(source)
        }.not_to raise_error
    end
  end
end

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/parsing/fixtures_spec.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/parsing/fixtures_spec.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/parsing/fixtures_spec.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/parsing/fixtures_spec.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/yajl-ruby-1.4.3/spec/parsing/fixtures_spec.rb
yajl-ruby-1.4.3 spec/parsing/fixtures_spec.rb
yajl-ruby-1.4.2 spec/parsing/fixtures_spec.rb
yajl-ruby-1.4.1 spec/parsing/fixtures_spec.rb
yajl-ruby-1.4.0 spec/parsing/fixtures_spec.rb
yajl-ruby-1.3.1 spec/parsing/fixtures_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/spec/parsing/fixtures_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/spec/parsing/fixtures_spec.rb
yajl-ruby-1.3.0 spec/parsing/fixtures_spec.rb