Sha256: f1c15c6e4353c2aef16ea73a85d137e5d701e057623e84ab2b0d4e4f6988a16a

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe NetSuite::Customer do
  let(:customer) { NetSuite::Customer.new }

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

      it 'returns a Customer instance populated with the data from the response object' do
        NetSuite::Actions::Customer::Get.should_receive(:call).with(1).and_return(response)
        customer = NetSuite::Customer.get(1)
        customer.should be_kind_of(NetSuite::Customer)
        customer.is_person.should be_true
      end
    end

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

      it 'returns a Customer instance populated with the data from the response object' do
        NetSuite::Actions::Customer::Get.should_receive(:call).with(1).and_return(response)
        lambda {
          NetSuite::Customer.get(1)
        }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Customer with ID=1 could not be found')
      end
    end
  end

  describe '#is_person' do
    context 'when the customer is a person' do
      it 'returns true' do
        customer = NetSuite::Customer.new(:is_person => true)
        customer.is_person.should be_true
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netsuite-0.0.2 spec/netsuite/models/customer_spec.rb