Sha256: 11b210c0d5567cc30efd97881c529fdddf1cc9b68978a0b19d1121202a096159

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Youku::V2::Searches do

  let(:client)   { Youku::Client.new(client_id: 'client-id') }
  let(:searches) { Youku::V2::Searches.new(client) }

  describe '#video' do
    subject { searches.video }

    it { expect(subject).to be_a Youku::V2::Searches::Video }
    it { expect(subject.client).to eq client }
  end

  describe '::Video' do
    let(:video) { Youku::V2::Searches::Video.new(client) }

    describe '#by_keyword' do
      let(:url) { 'https://openapi.youku.com/v2/searches/video/by_keyword.json' }
      let(:query) { {
        client_id: client.client_id,
        keyword:   2014,
        period:    'week',
        orderby:   'published',
        page:      1,
        count:     20
      } }

      before do
        stub_request(:get, url).with(query: query).to_return(status: 200)
      end

      subject { video.by_keyword(2014) }

      it_should_behave_like 'a base Youku API V2 requests'
    end

    describe '#by_tag' do
      let(:url) { 'https://openapi.youku.com/v2/searches/video/by_tag.json' }
      let(:query) { {
        client_id: client.client_id,
        tag:      2014,
        category: '',
        period:   'today',
        orderby:  'relevance',
        userid:   '',
        page:     1,
        count:    20
      } }

      before do
        stub_request(:get, url).with(query: query).to_return(status: 200)
      end

      subject { video.by_tag(tag: 2014) }

      it_should_behave_like 'a base Youku API V2 requests'
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
youku_client-0.0.4 spec/youku/v2/searches_spec.rb