require 'spec_helper.rb' describe Endicia::Refund, vcr: { record: :none } do # XXX: Hand-crafted, artisanal, small-batch VCR file subject(:refund) { described_class.new } describe "#request_refund" do let(:values) { { ToName: Faker::Name.name, ToCompany: Faker::Company.name, ToPostalCode: "90210", ToAddress1: Faker::Address.street_address, ToAddress2: Faker::Address.secondary_address, ToCity: Faker::Address.city, ToState: "CA", PartnerTransactionID: 12345, PartnerCustomerID: 45678, MailClass: "Priority", MailpieceShape: "Parcel", ToZIP4: '1234', WeightOz: "32", # 2 pounds MailpieceDimensions: { Length: "12", Width: "16", Height: "18", }, FromCompany: Faker::Company.name, ReturnAddress1: Faker::Address.street_address, ReturnAddress2: Faker::Address.secondary_address, FromCity: Faker::Address.city, FromState: "DC", FromPostalCode: "20005", FromZIP4: "1234", FromPhone: "2025551212", } } before do # get a couple real tracking number @tracking_numbers = [] label = Endicia::Label.new 2.times { create_label_response = label.request_label({ nodes: values, attrs: {} }, { log_requests: true, log_responses: true }) @tracking_numbers << create_label_response.tracking_number } @response = refund.request_refund(@tracking_numbers) end it "returns info about each tracking number" do # XXX: Do not rename this test as we had to hand-craft # the VCR file, since the test server doesn't support # refund requests expect(@response.success).to eq(true) expect(@response.form_number).to_not be_nil expect(@response.raw_response).to_not be_nil expect(@response.parsed_response).to_not be_nil expect(@response.tracking_numbers.size).to eq(@tracking_numbers.size) @tracking_numbers.each do |tracking_number| expect(@response.tracking_numbers[0].pic_number).to eq(tracking_number) expect(@response.tracking_numbers[0].approved).to eq(true) expect(@response.tracking_numbers[0].message).to_not be_nil end end end end