Sha256: e1ada575a21a1c66acbf6e4b674e967d302932c607c0ba81ceda78dc075013a1

Contents?: true

Size: 901 Bytes

Versions: 3

Compression:

Stored size: 901 Bytes

Contents

require_relative './../spec_helper'

module VzaarApi
  describe 'Category: Lookup' do

    let(:described_class) { Category }
    let(:id) { api_envs['category_id'] }

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

      context 'and resource can be found' do
        subject { described_class.find(id) }
        specify { expect(subject.id).to eq id }
      end

      context 'and resource cannot be found' do
        it 'raises an error' do
          expect{ described_class.find(-1) }.to raise_error(
            Error, 'Not found: Resource cannot be found')
        end
      end
    end

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

      it 'raises an error' do
        expect{ described_class.find(id) }.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/category/lookup_spec.rb
vzaar_api-2.0.1 examples/category/lookup_spec.rb
vzaar_api-2.0.0 examples/category/lookup_spec.rb