Sha256: 278f1c5759c6c8531e6b158fe74a9ac42d0042c11938e757a828847f8c38c3d9

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe ActionKitRest::User do
  before(:each) do
    @actionkit = ActionKitRest.new(host: 'test.com')

    logger = double
    logger.stub(:debug).and_return(true)

    ActionKitRest.stub(:logger).and_return(logger)
    Vertebrae::Base.stub(:logger).and_return(logger)
  end


  describe "retrieval" do
    let(:request_path) { 'user/1/' }

    before(:each) do
      stub_get(request_path).to_return(:body => body, :status => status,
                                       :headers => {:content_type => "application/json; charset=utf-8"})
    end

    describe ".get" do
      let(:body) { fixture('user/object.json') }
      let(:status) { 200 }

      it 'should return a user object' do
        @actionkit.user.get(1).email.should == 'walkers@wawd.com'
      end
    end

    describe 'user not found' do
      let(:body) { '' }
      let(:status) { 404 }

      it "should raise an exception" do
        expect { @actionkit.user.get(1) }.to raise_error(ActionKitRest::Response::NotFound)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
action_kit_rest-0.2.2 spec/action_kit_rest/user_spec.rb
action_kit_rest-0.2.1 spec/action_kit_rest/user_spec.rb