Sha256: d6e858d2aaac4f6d520897092047b837572372a6ba33ee2f91a9466bf70dfede

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'fortnox/api'
require 'fortnox/api/mappers'
require 'fortnox/api/repositories/customer'
require 'fortnox/api/repositories/examples/all'
require 'fortnox/api/repositories/examples/find'
require 'fortnox/api/repositories/examples/save'
require 'fortnox/api/repositories/examples/save_with_specially_named_attribute'
require 'fortnox/api/repositories/examples/search'

describe Fortnox::API::Repository::Article, order: :defined, integration: true do
  include Helpers::Configuration

  before { set_api_test_configuration }

  subject(:repository) { described_class.new }

  include_examples '.save',
                   :description,
                   additional_attrs: { sales_account: 1250 }

  include_examples '.save with specially named attribute',
                   { description: 'Test article' },
                   :ean,
                   '5901234123457'

  # When recording new VCR cassettes, expected matches must be increased
  include_examples '.all', 29

  # When recording new VCR cassettes, expected matches must be increased
  include_examples '.find', '1' do
    let(:find_by_hash_failure) { { description: 'Not Found' } }
    let(:single_param_find_by_hash) { { find_hash: { articlenumber: 1 }, matches: 13 } }

    let(:multi_param_find_by_hash) do
      { find_hash: { articlenumber: 1, description: 'Cykelpump' }, matches: 1 }
    end
  end

  include_examples '.search', :description, 'Testartikel', 2
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fortnox-api-0.8.0 spec/fortnox/api/repositories/article_spec.rb