Sha256: a238277e1630d43d590b9c57628e90a3049e512ebd312078c394a7a7bf584372

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require "spec_helper"

module EdiParser
  describe CarrierData do
    context "validate all attributes" do
      subject {
        CarrierData.new(cnpj: "Carrier cnpj", corporate_name: "Corporate name")
      }

      its(:cnpj) { should == "Carrier cnpj" }
      its(:corporate_name) { should == "Corporate name" }
    end

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

      it "raise InvalidCarrierDataError" do
        expect { CarrierData.parse(line) }.to raise_error(InvalidCarrierDataError)
      end
    end

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

      it "parse the carrier data" do
        carrier_data = CarrierData.parse(line)
        carrier_data.cnpj.should == "73939449000193"
        carrier_data.corporate_name.should == "TEX COURIER LTDA"
      end
    end

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

      it "parse the carrier data" do
        carrier_data = CarrierData.parse(line)
        carrier_data.cnpj.should == "09329143000116"
        carrier_data.corporate_name.should == "ONTIME LOGISTISTICA LTDA"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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