Sha256: b44698a80b0ca45f99ce8fbb5a340c3de162f7e0975fa8ed91a9361592340e7d

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 Bytes

Contents

require 'spec_helper'

describe Frenetic::MemberRestMethods do
  let(:test_cfg) { { url:'http://example.com/api' } }

  let(:my_temp_resource) do
    cfg = test_cfg

    Class.new(Frenetic::Resource) do
      api_client { Frenetic.new(cfg) }
    end
  end

  before do
    stub_const 'MyTempResource', my_temp_resource

    MyTempResource.send :include, described_class
  end

  describe '.find' do
    before { @stubs.api_description }

    subject { MyTempResource.find 1 }

    context 'for a known instance' do
      before { @stubs.known_resource }

      it 'should return the instance' do
        expect(subject).to be_a MyTempResource
      end
    end

    context 'for an unknown instance' do
      before { @stubs.unknown_resource }

      it 'should raise an error' do
        expect{ subject }.to raise_error Frenetic::ClientError
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
frenetic-0.0.20.alpha.3 spec/concerns/member_rest_methods_spec.rb
frenetic-0.0.20.alpha.2 spec/concerns/member_rest_methods_spec.rb
frenetic-0.0.20.alpha.1 spec/concerns/member_rest_methods_spec.rb
frenetic-0.0.20.alpha.0 spec/concerns/member_rest_methods_spec.rb