Sha256: e745857eeb19f2521fa08657a2c7c001883c9a1084b15f28fad196519c328e0d
Contents?: true
Size: 1.62 KB
Versions: 4
Compression:
Stored size: 1.62 KB
Contents
# encoding: utf-8 require 'spec_helper' require 'rakuten_web_service' describe RakutenWebService::Kobo::Ebook do let(:endpoint) { 'https://app.rakuten.co.jp/services/api/Kobo/EbookSearch/20131010' } let(:affiliate_id) { 'dummy_affiliate_id' } let(:application_id) { 'dummy_application_id' } let(:expected_query) do { :affiliateId => affiliate_id, :applicationId => application_id, :title => '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('kobo/ebook_search_with_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 ebooks = RakutenWebService::Kobo::Ebook.search(:title => 'Ruby') expect(@expected_request).to_not have_been_made ebook = ebooks.first expect(@expected_request).to have_been_made.once expect(ebook).to be_a(RWS::Kobo::Ebook) end end describe '#genre' do let(:response) { JSON.parse(fixture('kobo/ebook_search_with_Ruby.json')) } specify 'respond Kobo::Genre object' do stub_request(:get, endpoint).with(:query => expected_query). to_return(:body => response.to_json) expected_item = response['Items'][0]['Item'] RakutenWebService::Kobo::Genre.should_receive('new').with(expected_item['koboGenreId']) RakutenWebService::Kobo::Ebook.search(:title => 'Ruby').first.genre end end end
Version data entries
4 entries across 4 versions & 1 rubygems