Sha256: e2b074128468891da3c81e1228d2bd144284b44568f1c12cff22073ba50c8de5
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require 'spec_helper' describe Trebbianno::Order do let(:client) { Trebbianno::Client.new("the_username", "the_password") } let(:order_client) { Trebbianno::Order.new(client) } let(:xml) { Builder::XmlMarkup.new } describe '#build_order_request' do it 'should' do response = order_client.build_order_request(order_hash) expect(response).to eq read_xml(:test_build_order_request) end end describe 'private#build_address' do before do xml = ::Builder::XmlMarkup.new :indent => 3 xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" end it 'should build the proper address xml' do request = order_client.send(:build_address, xml, order_hash[:shipping_address]) expect(request).to eq read_xml(:test_build_address) end end describe 'private#build_line_items' do it 'should build the proper line items xml' do request = order_client.send(:build_line_items, xml, order_hash) expect(request).to eq test_line_items_string(order_hash) end end describe 'private#freight_charge' do it 'should claculate freight charges for order' do charge = order_client.send(:freight_charge, order_hash) expect(charge).to eq 30 end end describe 'private#line_item_discount' do let(:discount) {[10, 20]} it 'should calculate discount price for line item' do order_hash[:line_items].each_with_index do |item, index| discount_amount = order_client.send(:line_item_discount, item[:price], order_hash) expect(discount_amount).to eq discount[index] end end end describe 'private#line_item_total' do let(:total) {400} it 'should calculate total price for line items' do total_amount = order_client.send(:line_item_total, order_hash) expect(total_amount).to eq total end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trebbianno-ruby-api-0.0.7 | spec/lib/order_spec.rb |