Sha256: 70fee23dcab7ba1124f91b9a2f53001d98e7bac0c2b824dec0b360152a1667cc
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require 'spec_helper' require 'rakuten_web_service/ichiba/ranking' describe RakutenWebService::Ichiba::RankingItem do let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaItem/Ranking/20120927' } let(:affiliate_id) { 'affiliate_id' } let(:application_id) { 'application_id' } let(:expected_query) do { affiliateId: affiliate_id, applicationId: application_id } end before do response = JSON.parse(fixture('ichiba/ranking_search.json')) @expected_request = stub_request(:get, endpoint). with(query: expected_query).to_return(body: response.to_json) RakutenWebService.configure do |c| c.affiliate_id = affiliate_id c.application_id = application_id end end describe '.search' do let(:expected_json) do response = JSON.parse(fixture('ichiba/ranking_search.json')) response['Items'][0]['Item'] end before do @ranking_item = RakutenWebService::Ichiba::RankingItem.search({}).first end subject { @ranking_item } specify 'should call the endpoint once' do expect(@expected_request).to have_been_made.once end specify 'should be access by key' do expect(subject['itemName']).to eq(expected_json['itemName']) expect(subject['item_name']).to eq(expected_json['itemName']) end describe '#rank' do subject { super().rank } it { is_expected.to eq(1) } end describe '#name' do subject { super().name } it { is_expected.to eq(expected_json['itemName']) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rakuten_web_service-1.5.0 | spec/rakuten_web_service/ichiba/ranking_spec.rb |
rakuten_web_service-1.4.2 | spec/rakuten_web_service/ichiba/ranking_spec.rb |