Sha256: 4bf8aef6b59baea71eeaeacb3a8b870a7651d68a1c547f3b1b3b700f5bd44f45

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe NetSuite::Records::Classification do
  let(:classification) { NetSuite::Records::Classification.new }

  it 'has all the right fields' do
    [
      :name, :include_children, :is_inactive, :class_translation_list, :subsidiary_list, :custom_field_list
    ].each do |field|
      classification.should have_field(field)
    end
  end

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

      it 'returns an Invoice instance populated with the data from the response object' do
        NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Classification, :external_id => 10).and_return(response)
        invoice = NetSuite::Records::Classification.get(:external_id => 10)
        invoice.should be_kind_of(NetSuite::Records::Classification)
      end
    end

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

      it 'raises a RecordNotFound exception' do
        NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Classification, :external_id => 10).and_return(response)
        lambda {
          NetSuite::Records::Classification.get(:external_id => 10)
        }.should raise_error(NetSuite::RecordNotFound,
          /NetSuite::Records::Classification with OPTIONS=(.*) could not be found/)
      end
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
netsuite-0.0.26 spec/netsuite/records/classification_spec.rb
netsuite-0.0.25 spec/netsuite/records/classification_spec.rb
netsuite-0.0.23 spec/netsuite/records/classification_spec.rb
netsuite-0.0.22 spec/netsuite/records/classification_spec.rb
netsuite-0.0.21 spec/netsuite/records/classification_spec.rb
netsuite-0.0.20 spec/netsuite/records/classification_spec.rb
netsuite-0.0.19 spec/netsuite/records/classification_spec.rb
netsuite-0.0.18 spec/netsuite/records/classification_spec.rb
netsuite-0.0.17 spec/netsuite/records/classification_spec.rb
netsuite-0.0.16 spec/netsuite/records/classification_spec.rb