Sha256: 7cbca0cc59252fffa77da729b0229cc2aa28c62965c7973ffc283621153d5015

Contents?: true

Size: 1.46 KB

Versions: 3

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', 26

  # 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

3 entries across 3 versions & 1 rubygems

Version Path
fortnox-api-0.7.2 spec/fortnox/api/repositories/article_spec.rb
fortnox-api-0.7.1 spec/fortnox/api/repositories/article_spec.rb
fortnox-api-0.7.0 spec/fortnox/api/repositories/article_spec.rb