Sha256: 1b2929b9205dec4e98cd9ced86ba0fff7e04cce81267f413149e924ab9f46902

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
describe TMS::Client do
  context "creating a new client" do
    before do
      response = double('response', :status=>200, :body => {"_links" => [{"self" => "/"}, {"horse" => "/horses/new"}, {"rabbits" => "/rabbits"}]})
      @raw_connection = double('raw_connection', :get => response)
      @connection = TMS::Connection.stub(:new).and_return(double('connection', :connection => @raw_connection))
      @client = TMS::Client.new('auth_token', :api_root => 'null_url')
    end
    it 'should discover endpoints for known services' do
      @client.horse.should be_kind_of(TMS::Horse)
      @client.rabbits.should be_kind_of(TMS::Rabbits)
    end
    it 'should handle 4xx responses' do
      @raw_connection.stub(:get).and_return(double('response', :status => 404, :body => {'message' => 'hi'}))
      expect { @client.get('/blargh') }.to raise_error(TMS::Request::Error)
    end
    it 'should handle 202 responses' do
      @raw_connection.stub(:get).and_return(double('response', :status => 202, :body => {'message' => 'hi'}))
      expect { @client.get('/blargh') }.to raise_error(TMS::Request::InProgress)
    end
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tms_client-0.2.0 spec/client_spec.rb