Sha256: 318dadd37195100157297aadeb8858e7fcbd0739fcc960078beb59e5623c6d2b

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

shared_examples_for '.search' do |attribute_hash_key_name, value, matches|
  describe '.search' do
    describe 'search' do
      context 'with no matches' do
        subject do
          VCR.use_cassette("#{vcr_dir}/search_miss") do
            repository.search(attribute_hash_key_name => 'nothing')
          end
        end

        it { is_expected.to be_instance_of(Array) }
        it { is_expected.to have(0).entries }
      end

      context "with #{matches} match(es)" do
        subject do
          VCR.use_cassette("#{vcr_dir}/search_by_name") do
            repository.search(attribute_hash_key_name => value)
          end
        end

        it { is_expected.to be_instance_of(Array) }
        it { is_expected.to have(matches).entries }
      end

      context 'with special characters' do
        subject do
          when_performing do
            VCR.use_cassette("#{vcr_dir}/search_with_special_char") do
              repository.search(attribute_hash_key_name => 'special char å')
            end
          end
        end

        it { is_expected.not_to raise_error }
      end
    end
  end
end
# rubocop:enable RSpec/DescribeClass

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fortnox-api-0.8.2 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.8.1 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.8.0 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.7.2 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.7.1 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.7.0 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.6.3 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.6.2 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.6.1 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.6.0 spec/fortnox/api/repositories/examples/search.rb