Sha256: d10f07e8d020cbdb2f8b348acc278ede84e09588641fd143541602dbfe6fc854

Contents?: true

Size: 1.94 KB

Versions: 5

Compression:

Stored size: 1.94 KB

Contents

require 'spec_helper'

describe RakutenWebService::Gora::Plan do
  let(:endpoint) { 'https://app.rakuten.co.jp/services/api/Gora/GoraPlanSearch/20150706' }
  let(:affiliate_id) { 'dummy_affiliate_id' }
  let(:application_id) { 'dummy_application_id' }
  let(:expected_query) do
    {
        :affiliateId => affiliate_id,
        :applicationId => application_id,
        :areaCode => '12,14',
        :playDate => '2016-04-24',
    }
  end

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

  describe '.search' do
    before do
      response = JSON.parse(fixture('gora/plan_search_with_area_code.json'))
      @expected_request = stub_request(:get, endpoint).
          with(:query => expected_query).to_return(:body => response.to_json)
    end

    specify 'endpoint should not be called' do
      expect(@expected_request).to_not have_been_made
    end

    context 'just call the search method' do
      before do
        @plans = RakutenWebService::Gora::Plan.search(:areaCode => expected_query[:areaCode], :playDate => expected_query[:playDate])
      end

      specify 'endpoint should not be called' do
        expect(@expected_request).to_not have_been_made
      end

      describe 'a respond object' do
        let(:expected_json) do
          response = JSON.parse(fixture('gora/plan_search_with_area_code.json'))
          response['Items'][0]['Item']
        end

        subject { @plans.first }

        it { is_expected.to be_a RakutenWebService::Gora::Plan }
        specify 'should be accessed by key' do
          expect(subject['golfCourseId']).to eq(expected_json['golfCourseId'])
          expect(subject['golf_course_id']).to eq(expected_json['golfCourseId'])
        end

        describe '#golf_course_id' do
          subject { super().golf_course_id }
          it { is_expected.to eq(expected_json['golfCourseId']) }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rakuten_web_service-1.4.1 spec/rakuten_web_service/gora/plan_spec.rb
rakuten_web_service-1.4.0 spec/rakuten_web_service/gora/plan_spec.rb
rakuten_web_service-1.3.0 spec/rakuten_web_service/gora/plan_spec.rb
rakuten_web_service-1.2.0 spec/rakuten_web_service/gora/plan_spec.rb
rakuten_web_service-1.1.1 spec/rakuten_web_service/gora/plan_spec.rb