# encoding: utf-8
require 'spec_helper'
require 'timecop'
module Clearsale
describe Order do
before :each do
Timecop.freeze Time.parse('2012-07-01 11:13')
end
let(:_order) { Object.new(order) }
let(:_payment) { Object.new(payment) }
let(:_user) { Object.new(user) }
describe ".to_xml" do
it "converts the order to xml successfully" do
described_class.to_xml(_order, _payment, _user).should eq '12342012-07-01T11:13:00petergriffin@abc.com20.025.033127.0.0.18888124878346337Peter Löwenbräu Griffin1972-07-01T11:13:00petergriffin@abc.commBilling Street123Rhode IslandMaylandMaryland00100-011011800110028888124878346337Peter Löwenbräu Griffin1972-07-01T11:13:00petergriffin@abc.commShipping Street123Rhode IslandMaylandMaryland00100-011011800110022012-07-01T11:12:5850.0131234432111112222123443305/201224878346337Billing Street123Rhode IslandMaylandMaryland00100-011- 5555Pogobol5.027777Disney
- 5555Pogobol5.027777Disney
'
end
context "about credit card acquirer" do
it "should accept symbol" do
_payment.acquirer = :amex
described_class.to_xml(_order, _payment, _user).should include "#{Clearsale::Order::CARD_TYPE_MAP[:amex]}"
end
it "should accept string" do
_payment.acquirer = 'amex'
described_class.to_xml(_order, _payment, _user).should include "#{Clearsale::Order::CARD_TYPE_MAP[:amex]}"
end
end
context "when birthdate is empty" do
it "should not send birthdate" do
_user.birthdate = nil
described_class.to_xml(_order, _payment, _user).should_not include ""
end
it "should not send birthdate" do
_user.birthdate = nil
expect{ described_class.to_xml(_order, _payment, _user) }.to_not raise_error
end
end
end
end
end