Sha256: 0ad164068f549a902133b3044bb72b9dc5e0eb3280b1d97f57f7e2a560b7e0d6

Contents?: true

Size: 1.38 KB

Versions: 9

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

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/20170706' }
  let(:affiliate_id) { 'dummy_affiliate_id' }
  let(:application_id) { 'dummy_application_id' }
  let(:expected_query) do
    {
      'affiliateId' => affiliate_id,
      'applicationId' => application_id,
      'formatVersion' => '2',
      'shopCode' => 'hogeshop'
    }
  end

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

9 entries across 9 versions & 1 rubygems

Version Path
rakuten_web_service-1.13.2 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.13.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.13.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.12.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.11.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.10.0 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.9.2 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.9.1 spec/rakuten_web_service/ichiba/shop_spec.rb
rakuten_web_service-1.9.0 spec/rakuten_web_service/ichiba/shop_spec.rb