Sha256: 17de381eebd56856ccb9251d24e4d68a5eb0144a8efc04391a238c43cf631579

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'
require 'json'

describe Spectifly::Xsd::Builder do
  describe '.from_path' do
    it 'generates builder from entity at given path' do
      path_builder = Spectifly::Xsd::Builder.from_path(fixture_path('individual'))
      xsd_path = expectation_path('individual', 'xsd')
      xsd = path_builder.build
      xsd.should == File.read(xsd_path)
    end
  end

  describe '#build' do
    it 'returns an xsd representation of the entity' do
      entity = Spectifly::Entity.parse(fixture_path('individual'))
      xsd_path = expectation_path('individual', 'xsd')
      xsd = Spectifly::Xsd::Builder.new(entity).build
      xsd.should == File.read(xsd_path)
    end

    it 'includes import directives for custom field types' do
      entity = Spectifly::Entity.parse(fixture_path('group'))
      xsd_path = expectation_path('group', 'xsd')
      xsd = Spectifly::Xsd::Builder.new(entity).build
      xsd.should == File.read(xsd_path)
    end
  end

  describe '#present_as' do
    it 'filters entity through presenter, and returns self' do
      entity = Spectifly::Entity.parse(fixture_path('individual'))
      presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/positionless_individual'))
      xsd_path = expectation_path('presented/positionless_individual', 'xsd')
      builder = Spectifly::Xsd::Builder.new(entity)
      builder.present_as(presenter_entity).should == builder
      xsd = builder.build
      xsd.should == File.read(xsd_path)
    end

    it 'works with presented relationship-having entities' do
      entity = Spectifly::Entity.parse(fixture_path('group'))
      presenter_entity = Spectifly::Entity.parse(fixture_path('presenters/masterless_group'))
      xsd_path = expectation_path('presented/masterless_group', 'xsd')
      builder = Spectifly::Xsd::Builder.new(entity)
      builder.present_as(presenter_entity).should == builder
      xsd = builder.build
      xsd.should == File.read(xsd_path)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spectifly-0.0.2 spec/spectifly/xsd/builder_spec.rb
spectifly-0.0.1 spec/spectifly/xsd/builder_spec.rb