Sha256: c6636ac29ee363bcfc5e34d48d94997330448461140ec5a316eee5bb358dcb70

Contents?: true

Size: 1.61 KB

Versions: 6

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe CXML::OrderRequest do
  it { should respond_to :order_request_header }
  it { should respond_to :items_out }

  let(:data) { CXML::Parser.new(data: fixture('purchase_order_request_200.xml')).parse }
  let(:doc) { CXML::Document.new(data) }
  let(:order_request) { doc.request.order_request }
  let(:output_xml) { doc.to_xml }
  let(:output_data) { CXML::Parser.new(data: output_xml).parse }
  let(:order_request_output_data) { output_data[:request][:order_request] }

  describe '#to_xml' do
    it 'contains the required nodes' do
      order_request_output_data[:order_request_header].should_not be_empty
      order_request_output_data[:item_out].should be_a Array
      order_request_output_data[:item_out].length.should eq 2
    end
    it 'validates against the DTD' do
      next unless test_for_xmllint

      lint_doc_with_dtd(doc).should be true
    end
  end
  describe '#initialize' do
    it 'sets the required nodes' do
      order_request.order_request_header.should_not be_nil
      order_request.order_request_header.order_id.should_not be_nil
      order_request.items_out.first.should_not be_nil
    end
    it 'sets the required nodes via another  order request' do
      request = CXML::Document.new.from_xml(fixture('order_request.xml')).request
      request.order_request.order_request_header.should_not be_nil
      request.order_request.order_request_header.order_id.should_not be_nil
      request.order_request.items_out.first.should_not be_nil
      request.order_request.items_out.first.item_detail.extrinsics.first.should_not be_nil
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cxml-ruby-0.8.2 spec/purchase_order_request_spec.rb
cxml-ruby-0.8.1 spec/purchase_order_request_spec.rb
cxml-ruby-0.8.0 spec/purchase_order_request_spec.rb
cxml-ruby-0.7.0 spec/purchase_order_request_spec.rb
cxml-ruby-0.6.1 spec/purchase_order_request_spec.rb
cxml-ruby-0.6.0 spec/purchase_order_request_spec.rb