Sha256: 173e0b0f03348054c6f5231b8a2d04ae95a0fa6b5b3513800821a57b8ba9f16c

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

require 'spec_helper'

describe Fortnox::API::Customer::Validator do

  describe '.validate' do
    context 'Customer with valid, simple attributes' do
      it 'is valid' do
        customer = Fortnox::API::Customer.new( name: 'Test' )
        validator = Fortnox::API::Customer::Validator

        expect( validator.validate( customer )).to eql( true )
      end
    end

    context 'Customer with invalid sales_account' do

      let( :customer ){ Fortnox::API::Customer.new( sales_account: 99999 )}
      let( :validator ){ Fortnox::API::Customer::Validator }

      it 'is invalid' do
        expect( validator.validate( customer )).to eql( false )
      end

      it 'includes "sales_account" in violations' do
        validator.validate( customer )

        expect( validator.violations.inspect ).to include( 'sales_account' )
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.0.2 spec/fortnox/api/customer/validator_spec.rb