Sha256: 49255d879592d8783b5308b39ef1ed8286a80ce362df272f2cf589ca052f097b

Contents?: true

Size: 1.64 KB

Versions: 52

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe NetSuite::Support::Fields do
  let(:klass) { Class.new.send(:include, NetSuite::Support::Fields) }
  let(:instance) { klass.new }

  describe '.fields' do
    context 'with arguments' do
      it 'calls .field with each argument passed to it' do
        [:one, :two, :three].each do |field|
          expect(klass).to receive(:field).with(field)
        end
        klass.fields(:one, :two, :three)
      end
    end

    context 'without arguments' do
      it 'returns a Set of the field arguments' do
        arguments = [:one, :two, :three]
        klass.fields(*arguments)
        expect(klass.fields).to eql(Set.new(arguments))
      end
    end
  end

  describe '.field' do
    it 'defines instance accessor methods for the given field' do
      klass.field(:one)
      instance.one = 1
      expect(instance.one).to eql(1)
    end
  end

  describe '.read_only_fields' do
    context 'with arguments' do
      it 'calls .read_only_field with each argument passed to it' do
        [:one, :two, :three].each do |field|
          expect(klass).to receive(:read_only_field).with(field)
        end
        klass.read_only_fields(:one, :two, :three)
      end
    end

    context 'without arguments' do
      it 'returns a Set of the read_only_field arguments' do
        arguments = [:one, :two, :three]
        klass.read_only_fields(*arguments)
        expect(klass.read_only_fields).to eql(Set.new(arguments))
      end
    end
  end

  describe '.read_only_field' do
    it 'defines instance accessor methods for the given field' do
      expect(klass).to receive(:field).with(:one)
      klass.read_only_field(:one)
    end
  end

end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
netsuite-0.8.8 spec/netsuite/support/fields_spec.rb
netsuite-0.8.7 spec/netsuite/support/fields_spec.rb
netsuite-0.8.6 spec/netsuite/support/fields_spec.rb
netsuite-0.8.5 spec/netsuite/support/fields_spec.rb
netsuite-0.8.4 spec/netsuite/support/fields_spec.rb
netsuite-0.8.3 spec/netsuite/support/fields_spec.rb
netsuite-0.8.2 spec/netsuite/support/fields_spec.rb
netsuite-0.8.1 spec/netsuite/support/fields_spec.rb
netsuite-0.8.0 spec/netsuite/support/fields_spec.rb
netsuite-0.7.9 spec/netsuite/support/fields_spec.rb
netsuite-0.7.8 spec/netsuite/support/fields_spec.rb
netsuite-0.7.7 spec/netsuite/support/fields_spec.rb
netsuite-0.7.6 spec/netsuite/support/fields_spec.rb
netsuite-0.7.5 spec/netsuite/support/fields_spec.rb
netsuite-0.7.4 spec/netsuite/support/fields_spec.rb
netsuite-0.7.3 spec/netsuite/support/fields_spec.rb
netsuite-0.7.2 spec/netsuite/support/fields_spec.rb
netsuite-0.7.1 spec/netsuite/support/fields_spec.rb
netsuite-0.7.0 spec/netsuite/support/fields_spec.rb
netsuite-0.6.9 spec/netsuite/support/fields_spec.rb