Sha256: 1cf264bc9cf18743ef4db5f14ae979e9fcc2582b6ada52efdb545d6df1999293

Contents?: true

Size: 1.9 KB

Versions: 60

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe NetSuite::Records::PaymentMethod do
  let(:payment_method) { NetSuite::Records::PaymentMethod.new }

  it 'has all the right fields' do
    [
      :credit_card, :express_checkout_arrangement, :is_debit_card, :is_inactive, :is_online, :name, :pay_pal_email_address,
      :undep_funds, :use_express_checkout
    ].each do |field|
      expect(payment_method).to have_field(field)
    end
  end

  it 'has all thr right record refs' do
    [
      :account
    ].each do |record_ref|
      expect(payment_method).to have_record_ref(record_ref)
    end
  end

  describe '#merchant_accounts_list' do
    it 'can be set from attributes'
    it 'can be set from a RecordRefList object'
  end

  describe '.get' do
    context 'when the response is successful' do
      let(:response) { NetSuite::Response.new(:success => true, :body => { :is_debit_card => true }) }

      it 'returns an PaymentMethod instance populated with the data from the response object' do
        expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::PaymentMethod, :external_id => 10], {}).and_return(response)
        payment_method = NetSuite::Records::PaymentMethod.get(:external_id => 10)
        expect(payment_method).to be_kind_of(NetSuite::Records::PaymentMethod)
        expect(payment_method.is_debit_card).to be_truthy
      end
    end

    context 'when the response is unsuccessful' do
      let(:response) { NetSuite::Response.new(:success => false, :body => {}) }

      it 'raises a RecordNotFound exception' do
        expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::PaymentMethod, :external_id => 10], {}).and_return(response)
        expect {
          NetSuite::Records::PaymentMethod.get(:external_id => 10)
        }.to raise_error(NetSuite::RecordNotFound,
          /NetSuite::Records::PaymentMethod with OPTIONS=(.*) could not be found/)
      end
    end
  end

end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
netsuite-0.9.3 spec/netsuite/records/payment_method_spec.rb
netsuite-0.9.2 spec/netsuite/records/payment_method_spec.rb
netsuite-0.9.1 spec/netsuite/records/payment_method_spec.rb
netsuite-0.9.0 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.12 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.11 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.10 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.9 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.8 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.7 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.6 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.5 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.4 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.3 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.2 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.1 spec/netsuite/records/payment_method_spec.rb
netsuite-0.8.0 spec/netsuite/records/payment_method_spec.rb
netsuite-0.7.9 spec/netsuite/records/payment_method_spec.rb
netsuite-0.7.8 spec/netsuite/records/payment_method_spec.rb
netsuite-0.7.7 spec/netsuite/records/payment_method_spec.rb