Sha256: 2fd91a0029c8b810ac3f8ed21d6c877dce146438139f6b3538baa6b0da529f11

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

# rubocop:disable RSpec/DescribeClass
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

5 entries across 5 versions & 1 rubygems

Version Path
fortnox-api-0.5.2 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.5.1 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.5.0 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.4.0 spec/fortnox/api/repositories/examples/search.rb
fortnox-api-0.3.0 spec/fortnox/api/repositories/examples/search.rb