Sha256: 163a057440110be495f538c8c7f0d9bac656ece87de121d4ae6719694bdc86b1

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
require 'xway/api/http'
require 'xway/error'

describe Xway::Api::Http do
  let('headers') { {'X-App' => 'appway'} }
  let('request') do
    double('Xway::Api::Request').tap do |mock|
      mock.stub('method_name').and_return('get')
      mock.stub('path').and_return('/bar')
      mock.stub('http_options').and_return(headers: headers)
    end
  end

  it 'wraps errors' do
    HTTParty.stub('get') { raise StandardError, 'foo' }
    expect { subject.request 'http://foo', request }.to\
      raise_error(Xway::ConnectionError)
  end

  describe 'calls HTTParty' do
    it do
      HTTParty.should_receive('get').with('http://foo/bar',
                                          headers: headers)
      subject.request 'http://foo', request
    end

    it 'includes debug flag' do
      HTTParty.should_receive('get').with('http://foo/bar',
                                          headers: headers,
                                          debug_output: STDOUT)
      subject.request 'http://foo', request, true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xway-0.0.3.beta spec/lib/xway/api/http_spec.rb
xway-0.0.2.beta spec/lib/xway/api/http_spec.rb