Sha256: c343e1ec5de815031078ebd6694be1d6caefbaa90e23937cc1066a08f704ad46

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe RakutenWebService::Books::Total do
  let(:endpoint) { 'https://app.rakuten.co.jp/services/api/BooksTotal/Search/20130522' }
  let(:affiliate_id) { 'dummy_affiliate_id' }
  let(:application_id) { 'dummy_application_id' }
  let(:expected_query) do
    {
      affiliateId: affiliate_id,
      applicationId: application_id,
      formatVersion: '2',
      keyword: 'Ruby'
    }
  end

  before do
    RakutenWebService.configure do |c|
      c.affiliate_id = affiliate_id
      c.application_id = application_id
    end
  end

  describe '.search' do
    before do
      response = JSON.parse(fixture('books/total_search_with_keyword_Ruby.json'))
      @expected_request = stub_request(:get, endpoint).
        with(query: expected_query).to_return(body: response.to_json)
    end

    specify 'call endpoint when accessing results' do
      items = RakutenWebService::Books::Total.search(keyword: 'Ruby')
      expect(@expected_request).to_not have_been_made

      item = items.first
      expect(@expected_request).to have_been_made.once
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rakuten_web_service-1.8.0 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-1.7.0 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-1.6.1 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-1.6.0 spec/rakuten_web_service/books/total_spec.rb