Sha256: 742d0c60ee726eef3e486db4a6a64baf73265347945b01bc2ae460e6a2666afc

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

require_relative './../spec_helper'

module VzaarApi
  describe 'Playlist: List' do

    let(:described_class) { Playlist }

    context 'when user is authenticated' do
      before { setup_for :account_owner }

      describe '#each_item' do
        it 'retrieves the resource list' do
          ids = described_class.each_item.map(&:id)
          expect(ids).not_to be_empty
        end
      end

      describe '#paginate' do
        let(:pager) { described_class.paginate(page: 2, per_page: 1) }
        specify { expect(pager.first.count).to eq 1 }
        specify { expect(pager.next.count).to eq 1 }
        specify { expect(pager.previous.count).to eq 1 }
        specify { expect(pager.last.count).to eq 1 }
      end
    end

    context 'when user is not authenticated' do
      before { setup_for :intruder }

      it 'raises an error' do
        pager = described_class.paginate
        expect{ pager.first }.to raise_error(
          Error, 'Authentication failed: Invalid credentials')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vzaar_api-2.0.2 examples/playlist/list_spec.rb
vzaar_api-2.0.1 examples/playlist/list_spec.rb
vzaar_api-2.0.0 examples/playlist/list_spec.rb