Sha256: 32eeab1e6694a38f9d38084e906564b9f1fd60e37db2077cfddc76748e8b8e50

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

require 'rspec'
require 'rakuten_web_service'

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,
      :keyword => 'Ruby'
    }
  end

  before do
    RakutenWebService.configuration 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

9 entries across 9 versions & 1 rubygems

Version Path
rakuten_web_service-0.6.3 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.6.2 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.6.1 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.6.0 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.5.0 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.4.2 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.4.1 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.3.1 spec/rakuten_web_service/books/total_spec.rb
rakuten_web_service-0.3.0 spec/rakuten_web_service/books/total_spec.rb