Sha256: a44e8d21688977d5cce4d4b7517814cf8c47566f725e8daa5c2c4ff266213076

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'
require 'rakuten_web_service'

describe RakutenWebService::Ichiba::Shop do
  let(:params) do
    { 'shopName' => 'Hoge Shop',
      'shopCode' => 'hogeshop',
      'shopUrl' => 'http://www.rakuten.co.jp/hogeshop' }
  end
  let(:shop) { RakutenWebService::Ichiba::Shop.new(params) }
  let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaItem/Search/20130805' }
  let(:affiliate_id) { 'dummy_affiliate_id' }
  let(:application_id) { 'dummy_application_id' }
  let(:expected_query) do
    {
      'affiliateId' => affiliate_id,
      'applicationId' => application_id,
      'shopCode' => 'hogeshop'
    }
  end

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

  describe '.new' do
    specify 'returned object should have methods to fetch values' do
      expect(shop.name).to eq('Hoge Shop')
      expect(shop.code).to eq('hogeshop')
      expect(shop.url).to eq('http://www.rakuten.co.jp/hogeshop')
    end
  end

  describe '#items' do
    let(:response) do
      { 'Items' => [] }
    end

    before do
      @expected_request = stub_request(:get, endpoint).
        with(:query => expected_query).to_return(:body => response.to_json)
    end

    specify 'call the endpoint with the shopCode' do
      shop.items.first

      expect(@expected_request).to have_been_made
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rakuten_web_service-0.6.3 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.6.2 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.6.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.6.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.5.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.4.2 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.4.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.3.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.3.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.2.3 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.2.2 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.2.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-0.2.0 spec/rakuten_web_service/ichiba/shop_spec.rb