Sha256: 12d8a72077dd9d6ea7cbc4e51b0266e28b65d202b365738f07358ac2f8d2df81
Contents?: true
Size: 1.4 KB
Versions: 9
Compression:
Stored size: 1.4 KB
Contents
require 'helper' describe Terminal::Client do before do @client = Terminal::Client.new(:access_token => 'blah', :user_token => 'blah2') end describe 'new instance of the client is defined' do context 'when bad access_token,user_token are provided' do it 'raises a configuration exception' do expect { Terminal::Client.new(:access_token => 12121, :user_token => 12111111) }.to raise_exception(Terminal::APIConfigurationError) end end context 'when no access_token,user_token are provided' do it 'does not raise an exception' do expect { Terminal::Client.new }.not_to raise_error end end end describe 'connection' do it 'looks like a Faraday connection' do expect(@client.send(:connection)).to respond_to(:run_request) end end describe 'request' do it 'catches Faraday Timeout errors and raises an API timeout error' do allow(@client).to receive(:connection).and_raise(Faraday::Error::TimeoutError.new('expired')) expect { @client.send(:request, :post, '/blah') }.to raise_error(Terminal::APITimeoutError) end it 'raises an API error from a response containing error JSON' do stub_post('/path').to_return(:body => fixture('error_response.json'), :headers => {:content_type => 'application/json'}) expect { @client.send(:request, :post, '/path')}.to raise_error(Terminal::APIResponseError) end end end
Version data entries
9 entries across 9 versions & 1 rubygems