Sha256: 63efc78cf9001da31720d242809e8d4ba29cd1d2c6b1a5ca5e090c40e46e7bc7

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 Bytes

Contents

shared_examples "search request" do
  before(:each) do
    stub_request(:get, %r{www.europeana.eu/api/v2/search.json}).
      to_return(body: '{"success":true}')
  end

  it_behaves_like "API request"

  context "with API key" do
    let(:api_key) { 'xyz' }
    let(:params) { {} }

    before do
      Europeana::API.api_key = api_key
    end

    it "sends a Search request to the API" do
      subject
      expect(a_request(:get, %r{www.europeana.eu/api/v2/search.json})).
        to have_been_made.once
    end

    context "without query" do
      it "sets an empty query" do
        subject
        expect(a_request(:get, %r{www.europeana.eu/api/v2/search.json?query=})).
          to have_been_made.once
      end
    end

    context "with query" do
      let(:params) { { query: 'test' } }

      it "sends query" do
        subject
        expect(a_request(:get, %r{www.europeana.eu/api/v2/search.json?query=test})).
          to have_been_made.once
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
europeana-api-0.3.3 spec/support/shared_examples/search_request.rb