Sha256: 13b880d4c503a092d6f64cc85b8ac51d1bb64e23362cffd6220dfec134913dea

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

require 'spec_helper'

describe NetSuite::Actions::Add do
  before(:all) { savon.mock! }
  after(:all) { savon.unmock! }

  context 'Customer' do
    let(:customer) do
      NetSuite::Records::Customer.new(:entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.')
    end

    before do
      savon.expects(:add).with(:message => {
        'platformMsgs:record' => {
          :content! => {
            'listRel:entityId'    => 'Shutter Fly',
            'listRel:companyName' => 'Shutter Fly, Inc.'
          },
          '@xsi:type' => 'listRel:Customer'
        },
      }).returns(File.read('spec/support/fixtures/add/add_customer.xml'))
    end

    it 'makes a valid request to the NetSuite API' do
      NetSuite::Actions::Add.call(customer)
    end

    it 'returns a valid Response object' do
      response = NetSuite::Actions::Add.call(customer)
      response.should be_kind_of(NetSuite::Response)
      response.should be_success
    end
  end

  context 'Invoice' do
    let(:invoice) do
      NetSuite::Records::Invoice.new(:source => 'Google', :total => 100.0)
    end

    before do
      savon.expects(:add).with(:message => {
        'platformMsgs:record' => {
          :content! => {
            'tranSales:source' => 'Google'
          },
          '@xsi:type' => 'tranSales:Invoice'
        },
      }).returns(File.read('spec/support/fixtures/add/add_invoice.xml'))
    end

    it 'makes a valid request to the NetSuite API' do
      NetSuite::Actions::Add.call(invoice)
    end

    it 'returns a valid Response object' do
      response = NetSuite::Actions::Add.call(invoice)
      response.should be_kind_of(NetSuite::Response)
      response.should be_success
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netsuite-0.2.0 spec/netsuite/actions/add_spec.rb