Sha256: 2fc8e60366945687f8860f463d84e9d999de77f172f09fc589f52bf09389b90d

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 KB

Contents

require 'spec_helper'

describe OData4::NavigationProperty do
  let(:options) { {
      name: 'Categories',
      type: 'Collection(ODataDemo.Category)',
      partner: 'Products',
  } }
  let(:subject) do
    OData4::NavigationProperty.new(options)
  end

  it { expect(subject).to respond_to(:name) }
  it { expect(subject.name).to eq('Categories') }

  it { expect(subject).to respond_to(:type) }
  it { expect(subject.type).to eq('Collection(ODataDemo.Category)') }

  it { expect(subject).to respond_to(:nav_type) }
  it { expect(subject.nav_type).to eq(:collection) }

  it { expect(subject).to respond_to(:nullable) }

  it { expect(subject).to respond_to(:partner) }
  it { expect(subject.partner).to eq('Products') }

  describe '.new' do
    it 'requires name' do
      expect {
        OData4::NavigationProperty.new(type: 'Collection(ODataDemo.Category)')
      }.to raise_error(ArgumentError)
    end

    it 'requires type' do
      expect {
        OData4::NavigationProperty.new(name: 'Categories')
      }.to raise_error(ArgumentError)
    end
  end

  describe '#build' do
    let(:metadata_file) { File.read 'spec/fixtures/files/metadata.xml' }
    let(:metadata_xml)  { Nokogiri::XML(metadata_file).remove_namespaces! }
    let(:navigation_properties) { metadata_xml.xpath('//NavigationProperty') }
    let(:subject) {
      OData4::NavigationProperty.build(navigation_properties.first)
    }

    it { expect(subject.name).to eq('Categories') }
    it { expect(subject.type).to eq('Collection(ODataDemo.Category)') }
    it { expect(subject.partner).to eq('Products') }
    it { expect(subject.nullable).to eq(true) }
    it { expect(subject.nav_type).to eq(:collection) }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
odata4-0.9.1 spec/odata4/navigation_property_spec.rb
odata4-0.9.0 spec/odata4/navigation_property_spec.rb
odata4-0.8.2 spec/odata4/navigation_property_spec.rb
odata4-0.8.1 spec/odata4/navigation_property_spec.rb
odata4-0.8.0 spec/odata4/navigation_property_spec.rb
odata4-0.7.0 spec/odata4/navigation_property_spec.rb