Sha256: ed93738e88aef6061f07acceb06263ab9cc9139e0013263ccacb69a115617a33

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Fidor::Schema do

  context 'path' do
    it 'should provide path to schema files' do
      expect(Fidor::Schema.path).to eq(File.expand_path( File.join('../schema/v1.0'), File.dirname(__FILE__)))
    end
  end

  context 'read schemata' do
    it 'should read all json files' do
      SchemaTools.schema_path = Fidor::Schema.path
      SchemaTools::Reader.read_all
      expect(SchemaTools::Reader.registry).to_not be_empty
    end
  end

  context 'resolves $refs' do
    it 'in single schema' do
      SchemaTools.schema_path = Fidor::Schema.path
      schema = SchemaTools::Reader.read('account').to_h
      expect(schema['properties']['customers']['items']['properties']['id']['type']).to eq 'string'
    end

    it 'should resolve all' do
      SchemaTools.schema_path = Fidor::Schema.path
      SchemaTools::Reader.read_all
      out = []
      SchemaTools::Reader.registry.each{|n, i|
        out << "#{i.to_h}"
      }
      expect(out).to_not include('$ref')
    end
  end

  context 'validate schemata' do
    it 'should validate all' do
      schema_path = Fidor::Schema.path
      errors = JsonSchemaValidator.validate_schemas(schema_path)
      errors.each do |name, error|
        expect(error).to be_empty
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fidor_schema-0.10.16 spec/fidor_schema_spec.rb
fidor_schema-0.10.15 spec/fidor_schema_spec.rb
fidor_schema-0.10.14 spec/fidor_schema_spec.rb