Sha256: 2f081cfd16f92ae8d454c23f827221c4aa59360ec9de358708277bee07772f3b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require "spec_helper"

module EdiParser
  describe DocumentHeader do
    context "validate all attributes" do
      subject {
        DocumentHeader.new("Document id")
      }

      its(:document_id) { should == "Document id" }
    end

    context "parse invalid ocurrence EDI file" do
      let(:line) { get_line(filename: "OCOR_invalid.txt") }

      it "raise InvalidDocumentHeaderError" do
        expect { DocumentHeader.parse(line) }.to raise_error(InvalidDocumentHeaderError)
      end
    end

    context "parse valid ocurrence EDI file" do
      let(:line) { get_line(filename: "OCOR_valid.txt", line_number: 2) }

      it "parse the document header" do
        document_header = DocumentHeader.parse(line)
        document_header.document_id.should == "OCORR070611053"
      end
    end

    context "parse valid ONTIME ocurrence EDI file" do
      let(:line) { get_line(filename: "OCOR_ONTIME_valid.txt", line_number: 2) }

      it "parse the document header" do
        document_header = DocumentHeader.parse(line)
        document_header.document_id.should == "240520131406OCOR1_ONTIME"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
edi_parser-0.0.1 spec/edi_parser/document_header_spec.rb