2009-07-19 19:17:33 -04:00
require File . expand_path ( File . join ( File . dirname ( __FILE__ ) , 'spec_helper' ) )
2008-07-27 11:52:18 -04:00
2014-12-06 19:28:17 -05:00
RSpec . describe HTTParty do
2009-01-28 23:41:01 -05:00
before ( :each ) do
@klass = Class . new
@klass . instance_eval { include HTTParty }
end
2010-11-24 12:27:45 -05:00
describe " pem " do
it 'should set the pem content' do
@klass . pem 'PEM-CONTENT'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :pem ] ) . to eq ( 'PEM-CONTENT' )
2010-11-24 12:27:45 -05:00
end
it " should set the password to nil if it's not provided " do
@klass . pem 'PEM-CONTENT'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :pem_password ] ) . to be_nil
2010-11-24 12:27:45 -05:00
end
it 'should set the password' do
@klass . pem 'PEM-CONTENT' , 'PASSWORD'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :pem_password ] ) . to eq ( 'PASSWORD' )
2010-11-24 12:27:45 -05:00
end
end
2009-12-05 21:00:36 -05:00
2013-10-22 06:45:03 -04:00
describe " pkcs12 " do
it 'should set the p12 content' do
@klass . pkcs12 'P12-CONTENT' , 'PASSWORD'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :p12 ] ) . to eq ( 'P12-CONTENT' )
2013-10-22 06:45:03 -04:00
end
it 'should set the password' do
@klass . pkcs12 'P12-CONTENT' , 'PASSWORD'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :p12_password ] ) . to eq ( 'PASSWORD' )
2013-10-22 06:45:03 -04:00
end
end
2012-08-20 09:08:25 -04:00
describe 'ssl_version' do
it 'should set the ssl_version content' do
@klass . ssl_version :SSLv3
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :ssl_version ] ) . to eq ( :SSLv3 )
2012-08-20 09:08:25 -04:00
end
end
2012-11-30 14:08:17 -05:00
describe 'ciphers' do
it 'should set the ciphers content' do
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :ciphers ] ) . to be_nil
2012-11-30 14:08:17 -05:00
@klass . ciphers 'RC4-SHA'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :ciphers ] ) . to eq ( 'RC4-SHA' )
2012-11-30 14:08:17 -05:00
end
end
2012-03-28 11:51:31 -04:00
describe 'http_proxy' do
it 'should set the address' do
@klass . http_proxy 'proxy.foo.com' , 80
options = @klass . default_options
2014-12-06 19:12:39 -05:00
expect ( options [ :http_proxyaddr ] ) . to eq ( 'proxy.foo.com' )
expect ( options [ :http_proxyport ] ) . to eq ( 80 )
2012-03-28 11:51:31 -04:00
end
it 'should set the proxy user and pass when they are provided' do
@klass . http_proxy 'proxy.foo.com' , 80 , 'user' , 'pass'
options = @klass . default_options
2014-12-06 19:12:39 -05:00
expect ( options [ :http_proxyuser ] ) . to eq ( 'user' )
expect ( options [ :http_proxypass ] ) . to eq ( 'pass' )
2012-03-28 11:51:31 -04:00
end
end
2008-07-28 12:08:21 -04:00
describe " base uri " do
2009-01-28 23:41:01 -05:00
before ( :each ) do
@klass . base_uri ( 'api.foo.com/v1' )
2008-11-08 13:59:57 -05:00
end
2008-11-08 11:18:25 -05:00
it " should have reader " do
2014-12-06 19:12:39 -05:00
expect ( @klass . base_uri ) . to eq ( 'http://api.foo.com/v1' )
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
2008-11-08 11:18:25 -05:00
it 'should have writer' do
2009-01-28 23:41:01 -05:00
@klass . base_uri ( 'http://api.foobar.com' )
2014-12-06 19:12:39 -05:00
expect ( @klass . base_uri ) . to eq ( 'http://api.foobar.com' )
2008-07-28 12:08:21 -04:00
end
2009-03-03 11:13:41 -05:00
it 'should not modify the parameter during assignment' do
uri = 'http://api.foobar.com'
@klass . base_uri ( uri )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'http://api.foobar.com' )
2009-03-03 11:13:41 -05:00
end
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
2010-12-10 16:47:42 -05:00
describe " .disable_rails_query_string_format " do
it " sets the query string normalizer to HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER " do
@klass . disable_rails_query_string_format
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :query_string_normalizer ] ) . to eq ( HTTParty :: Request :: NON_RAILS_QUERY_STRING_NORMALIZER )
2010-12-10 16:47:42 -05:00
end
end
describe " .normalize_base_uri " do
2008-12-06 23:41:28 -05:00
it " should add http if not present for non ssl requests " do
uri = HTTParty . normalize_base_uri ( 'api.foobar.com' )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'http://api.foobar.com' )
2008-12-06 23:41:28 -05:00
end
2009-09-08 23:34:21 -04:00
2008-12-06 23:41:28 -05:00
it " should add https if not present for ssl requests " do
uri = HTTParty . normalize_base_uri ( 'api.foo.com/v1:443' )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'https://api.foo.com/v1:443' )
2008-12-06 23:41:28 -05:00
end
2009-09-08 23:34:21 -04:00
2008-12-06 23:41:28 -05:00
it " should not remove https for ssl requests " do
uri = HTTParty . normalize_base_uri ( 'https://api.foo.com/v1:443' )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'https://api.foo.com/v1:443' )
2008-12-06 23:41:28 -05:00
end
2009-03-03 11:13:41 -05:00
it 'should not modify the parameter' do
uri = 'http://api.foobar.com'
HTTParty . normalize_base_uri ( uri )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'http://api.foobar.com' )
2009-03-03 11:13:41 -05:00
end
2012-05-04 18:26:55 -04:00
it " should not treat uri's with a port of 4430 as ssl " do
uri = HTTParty . normalize_base_uri ( 'http://api.foo.com:4430/v1' )
2014-12-06 19:12:39 -05:00
expect ( uri ) . to eq ( 'http://api.foo.com:4430/v1' )
2012-05-04 18:26:55 -04:00
end
2008-12-06 23:41:28 -05:00
end
2009-09-08 23:34:21 -04:00
2008-07-28 12:08:21 -04:00
describe " headers " do
2015-04-18 06:27:50 -04:00
def expect_headers ( header = { } )
2014-12-06 19:12:39 -05:00
expect ( HTTParty :: Request ) . to receive ( :new ) \
2014-05-15 16:45:32 -04:00
. with ( anything , anything , hash_including ( { headers : header } ) ) \
2014-12-06 19:12:39 -05:00
. and_return ( double ( " mock response " , perform : nil ) )
2009-08-21 20:32:15 -04:00
end
2009-09-08 19:02:09 -04:00
2017-04-12 18:01:29 -04:00
it " does not modify default_options when no arguments are passed " do
@klass . headers
expect ( @klass . default_options [ :headers ] ) . to eq ( nil )
end
2008-07-28 12:08:21 -04:00
it " should default to empty hash " do
2014-12-06 19:12:39 -05:00
expect ( @klass . headers ) . to eq ( { } )
2008-07-28 12:08:21 -04:00
end
2009-09-08 19:02:09 -04:00
2008-07-28 12:08:21 -04:00
it " should be able to be updated " do
2014-05-15 16:45:32 -04:00
init_headers = { foo : 'bar' , baz : 'spax' }
2009-01-28 23:41:01 -05:00
@klass . headers init_headers
2014-12-06 19:12:39 -05:00
expect ( @klass . headers ) . to eq ( init_headers )
2008-07-28 12:08:21 -04:00
end
2009-09-08 19:02:09 -04:00
it " uses the class headers when sending a request " do
2014-05-15 16:45:32 -04:00
expect_headers ( foo : 'bar' )
@klass . headers ( foo : 'bar' )
2009-09-08 19:02:09 -04:00
@klass . get ( '' )
end
2014-02-08 23:02:18 -05:00
it " merges class headers with request headers " do
2014-05-15 16:45:32 -04:00
expect_headers ( baz : 'spax' , foo : 'bar' )
@klass . headers ( foo : 'bar' )
@klass . get ( '' , headers : { baz : 'spax' } )
2009-09-08 19:02:09 -04:00
end
2014-02-08 23:02:18 -05:00
it 'overrides class headers with request headers' do
2014-05-15 16:45:32 -04:00
expect_headers ( baz : 'spax' , foo : 'baz' )
@klass . headers ( foo : 'bar' )
@klass . get ( '' , headers : { baz : 'spax' , foo : 'baz' } )
2014-02-08 23:02:18 -05:00
end
2009-09-08 19:02:09 -04:00
context " with cookies " do
it 'utilizes the class-level cookies' do
2014-05-15 16:45:32 -04:00
expect_headers ( foo : 'bar' , 'cookie' = > 'type=snickerdoodle' )
@klass . headers ( foo : 'bar' )
@klass . cookies ( type : 'snickerdoodle' )
2009-09-08 19:02:09 -04:00
@klass . get ( '' )
2009-08-21 20:32:15 -04:00
end
2009-09-08 19:02:09 -04:00
it 'adds cookies to the headers' do
2014-05-15 16:45:32 -04:00
expect_headers ( foo : 'bar' , 'cookie' = > 'type=snickerdoodle' )
@klass . headers ( foo : 'bar' )
@klass . get ( '' , cookies : { type : 'snickerdoodle' } )
2009-08-21 20:32:15 -04:00
end
2009-09-08 19:02:09 -04:00
2017-04-12 18:01:29 -04:00
it 'doesnt modify default headers' do
2014-12-06 19:12:39 -05:00
expect ( @klass . headers ) . to eq ( { } )
2014-07-09 08:04:32 -04:00
expect_headers ( 'cookie' = > 'type=snickerdoodle' )
@klass . get ( '' , cookies : { type : 'snickerdoodle' } )
2017-04-12 18:01:29 -04:00
expect ( @klass . headers ) . to eq ( { } )
2014-07-09 08:04:32 -04:00
end
2009-09-08 19:02:09 -04:00
it 'adds optional cookies to the optional headers' do
2014-05-15 16:45:32 -04:00
expect_headers ( baz : 'spax' , 'cookie' = > 'type=snickerdoodle' )
@klass . get ( '' , cookies : { type : 'snickerdoodle' } , headers : { baz : 'spax' } )
2009-08-21 20:32:15 -04:00
end
end
2008-07-28 11:56:58 -04:00
end
2009-01-28 23:54:42 -05:00
describe " cookies " do
def expect_cookie_header ( s )
2014-12-06 19:12:39 -05:00
expect ( HTTParty :: Request ) . to receive ( :new ) \
2014-05-15 16:45:32 -04:00
. with ( anything , anything , hash_including ( { headers : { " cookie " = > s } } ) ) \
2014-12-06 19:12:39 -05:00
. and_return ( double ( " mock response " , perform : nil ) )
2009-01-28 23:54:42 -05:00
end
it " should not be in the headers by default " do
2014-12-06 19:12:39 -05:00
allow ( HTTParty :: Request ) . to receive ( :new ) . and_return ( double ( nil , perform : nil ) )
2009-01-28 23:54:42 -05:00
@klass . get ( " " )
2014-12-06 19:12:39 -05:00
expect ( @klass . headers . keys ) . not_to include ( " cookie " )
2009-01-28 23:54:42 -05:00
end
it " should raise an ArgumentError if passed a non-Hash " do
2014-12-06 19:12:39 -05:00
expect do
2009-01-28 23:54:42 -05:00
@klass . cookies ( " nonsense " )
2014-12-06 19:12:39 -05:00
end . to raise_error ( ArgumentError )
2009-01-28 23:54:42 -05:00
end
it " should allow a cookie to be specified with a one-off request " do
expect_cookie_header " type=snickerdoodle "
2014-05-15 16:45:32 -04:00
@klass . get ( " " , cookies : { type : " snickerdoodle " } )
2009-01-28 23:54:42 -05:00
end
describe " when a cookie is set at the class level " do
before ( :each ) do
2014-05-15 16:45:32 -04:00
@klass . cookies ( { type : " snickerdoodle " } )
2009-01-28 23:54:42 -05:00
end
it " should include that cookie in the request " do
expect_cookie_header " type=snickerdoodle "
@klass . get ( " " )
end
2009-06-23 20:28:42 -04:00
it " should pass the proper cookies when requested multiple times " do
2 . times do
expect_cookie_header " type=snickerdoodle "
@klass . get ( " " )
end
end
2009-01-28 23:54:42 -05:00
it " should allow the class defaults to be overridden " do
expect_cookie_header " type=chocolate_chip "
2014-05-15 16:45:32 -04:00
@klass . get ( " " , cookies : { type : " chocolate_chip " } )
2009-01-28 23:54:42 -05:00
end
end
describe " in a class with multiple methods that use different cookies " do
before ( :each ) do
@klass . instance_eval do
def first_method
2014-05-15 16:45:32 -04:00
get ( " first_method " , cookies : { first_method_cookie : " foo " } )
2009-01-28 23:54:42 -05:00
end
def second_method
2014-05-15 16:45:32 -04:00
get ( " second_method " , cookies : { second_method_cookie : " foo " } )
2009-01-28 23:54:42 -05:00
end
end
end
it " should not allow cookies used in one method to carry over into other methods " do
expect_cookie_header " first_method_cookie=foo "
@klass . first_method
expect_cookie_header " second_method_cookie=foo "
@klass . second_method
end
end
end
2009-09-08 23:34:21 -04:00
2008-07-28 12:40:40 -04:00
describe " default params " do
it " should default to empty hash " do
2014-12-06 19:12:39 -05:00
expect ( @klass . default_params ) . to eq ( { } )
2008-07-28 12:40:40 -04:00
end
2009-09-08 23:34:21 -04:00
2008-07-28 12:40:40 -04:00
it " should be able to be updated " do
2014-05-15 16:45:32 -04:00
new_defaults = { foo : 'bar' , baz : 'spax' }
2009-01-28 23:41:01 -05:00
@klass . default_params new_defaults
2014-12-06 19:12:39 -05:00
expect ( @klass . default_params ) . to eq ( new_defaults )
2008-07-28 12:40:40 -04:00
end
end
2009-09-08 23:34:21 -04:00
2010-04-12 04:45:27 -04:00
describe " default timeout " do
it " should default to nil " do
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :timeout ] ) . to eq ( nil )
2010-04-12 04:45:27 -04:00
end
it " should support updating " do
@klass . default_timeout 10
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :timeout ] ) . to eq ( 10 )
2010-04-12 04:45:27 -04:00
end
2011-02-17 13:55:48 -05:00
it " should support floats " do
@klass . default_timeout 0 . 5
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :timeout ] ) . to eq ( 0 . 5 )
2011-02-17 13:55:48 -05:00
end
2010-04-12 04:45:27 -04:00
end
2010-01-24 22:59:55 -05:00
describe " debug_output " do
it " stores the given stream as a default_option " do
@klass . debug_output $stdout
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :debug_output ] ) . to eq ( $stdout )
2010-01-24 22:59:55 -05:00
end
it " stores the $stderr stream by default " do
@klass . debug_output
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :debug_output ] ) . to eq ( $stderr )
2010-01-24 22:59:55 -05:00
end
end
2008-07-28 12:08:21 -04:00
describe " basic http authentication " do
it " should work " do
2009-01-28 23:41:01 -05:00
@klass . basic_auth 'foobar' , 'secret'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :basic_auth ] ) . to eq ( { username : 'foobar' , password : 'secret' } )
2008-07-28 12:08:21 -04:00
end
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
2010-02-09 21:50:53 -05:00
describe " digest http authentication " do
it " should work " do
@klass . digest_auth 'foobar' , 'secret'
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :digest_auth ] ) . to eq ( { username : 'foobar' , password : 'secret' } )
2010-02-09 21:50:53 -05:00
end
end
2009-09-08 23:34:21 -04:00
describe " parser " do
2010-07-18 14:16:56 -04:00
class CustomParser
def self . parse ( body )
2015-04-18 07:15:24 -04:00
{ sexy : true }
2010-07-18 14:16:56 -04:00
end
end
2009-12-05 21:00:36 -05:00
let ( :parser ) do
2015-04-18 06:39:39 -04:00
proc { | data , format | CustomParser . parse ( data ) }
2009-09-08 23:34:21 -04:00
end
it " should set parser options " do
2009-12-05 21:00:36 -05:00
@klass . parser parser
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :parser ] ) . to eq ( parser )
2009-09-08 23:34:21 -04:00
end
it " should be able parse response with custom parser " do
2009-12-05 21:00:36 -05:00
@klass . parser parser
2014-05-15 16:45:32 -04:00
FakeWeb . register_uri ( :get , 'http://twitter.com/statuses/public_timeline.xml' , body : 'tweets' )
2009-09-08 23:34:21 -04:00
custom_parsed_response = @klass . get ( 'http://twitter.com/statuses/public_timeline.xml' )
2014-12-06 19:12:39 -05:00
expect ( custom_parsed_response [ :sexy ] ) . to eq ( true )
2009-09-08 23:34:21 -04:00
end
2009-12-05 21:00:36 -05:00
it " raises UnsupportedFormat when the parser cannot handle the format " do
@klass . format :json
class MyParser < HTTParty :: Parser
SupportedFormats = { }
2010-05-04 23:09:28 -04:00
end unless defined? ( MyParser )
2009-12-05 21:00:36 -05:00
expect do
@klass . parser MyParser
end . to raise_error ( HTTParty :: UnsupportedFormat )
end
it 'does not validate format whe custom parser is a proc' do
expect do
@klass . format :json
@klass . parser lambda { | body , format | }
2014-12-06 19:12:39 -05:00
end . to_not raise_error
2009-12-05 21:00:36 -05:00
end
2009-09-08 23:34:21 -04:00
end
2015-05-14 02:12:27 -04:00
describe " uri_adapter " do
require 'forwardable'
class CustomURIAdaptor
extend Forwardable
def_delegators :@uri , :userinfo , :relative? , :query , :query = , :scheme , :path , :host , :port
def initialize uri
@uri = uri
end
def self . parse uri
new URI . parse uri
end
end
let ( :uri_adapter ) { CustomURIAdaptor }
it " should set the uri_adapter " do
@klass . uri_adapter uri_adapter
expect ( @klass . default_options [ :uri_adapter ] ) . to be uri_adapter
end
it " should raise an ArgumentError if uri_adapter doesn't implement parse method " do
expect do
@klass . uri_adapter double ( )
end . to raise_error ( ArgumentError )
end
it " should process a request with a uri instance parsed from the uri_adapter " do
uri = 'http://foo.com/bar'
FakeWeb . register_uri ( :get , uri , body : 'stuff' )
@klass . uri_adapter uri_adapter
expect ( @klass . get ( uri ) . parsed_response ) . to eq ( 'stuff' )
end
end
2012-08-13 19:36:35 -04:00
describe " connection_adapter " do
2012-08-10 17:01:50 -04:00
let ( :uri ) { 'http://google.com/api.json' }
2014-12-06 19:12:39 -05:00
let ( :connection_adapter ) { double ( 'CustomConnectionAdapter' ) }
2012-08-10 17:01:50 -04:00
2012-08-13 19:36:35 -04:00
it " should set the connection_adapter " do
@klass . connection_adapter connection_adapter
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :connection_adapter ] ) . to be connection_adapter
2012-08-13 19:36:35 -04:00
end
it " should set the connection_adapter_options when provided " do
2014-05-15 16:45:32 -04:00
options = { foo : :bar }
2012-08-13 19:36:35 -04:00
@klass . connection_adapter connection_adapter , options
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :connection_adapter_options ] ) . to be options
2012-08-13 19:36:35 -04:00
end
it " should not set the connection_adapter_options when not provided " do
@klass . connection_adapter connection_adapter
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :connection_adapter_options ] ) . to be_nil
2012-08-10 17:01:50 -04:00
end
2012-08-13 19:36:35 -04:00
it " should process a request with a connection from the adapter " do
2014-05-15 16:45:32 -04:00
connection_adapter_options = { foo : :bar }
2015-04-18 06:29:00 -04:00
expect ( connection_adapter ) . to receive ( :call ) { | u , o |
2014-12-06 19:12:39 -05:00
expect ( o [ :connection_adapter_options ] ) . to eq ( connection_adapter_options )
2015-04-18 06:29:00 -04:00
HTTParty :: ConnectionAdapter . call ( u , o )
2014-12-06 19:12:39 -05:00
} . with ( URI . parse ( uri ) , kind_of ( Hash ) )
2014-05-15 16:45:32 -04:00
FakeWeb . register_uri ( :get , uri , body : 'stuff' )
2012-08-13 19:36:35 -04:00
@klass . connection_adapter connection_adapter , connection_adapter_options
2014-12-09 00:01:13 -05:00
expect ( @klass . get ( uri ) . parsed_response ) . to eq ( 'stuff' )
2012-08-10 17:01:50 -04:00
end
end
2008-07-28 11:56:58 -04:00
describe " format " do
it " should allow xml " do
2009-01-28 23:41:01 -05:00
@klass . format :xml
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :format ] ) . to eq ( :xml )
2008-07-28 11:56:58 -04:00
end
2009-09-08 23:34:21 -04:00
2014-02-08 12:32:43 -05:00
it " should allow csv " do
@klass . format :csv
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :format ] ) . to eq ( :csv )
2014-02-08 12:32:43 -05:00
end
2008-07-28 11:56:58 -04:00
it " should allow json " do
2009-01-28 23:41:01 -05:00
@klass . format :json
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :format ] ) . to eq ( :json )
2008-07-28 11:56:58 -04:00
end
2009-09-08 23:34:21 -04:00
2009-03-05 15:53:13 -05:00
it " should allow plain " do
@klass . format :plain
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :format ] ) . to eq ( :plain )
2009-03-05 15:53:13 -05:00
end
2009-09-08 23:34:21 -04:00
2008-07-28 11:56:58 -04:00
it 'should not allow funky format' do
2014-12-06 19:12:39 -05:00
expect do
2009-01-28 23:41:01 -05:00
@klass . format :foobar
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: UnsupportedFormat )
2008-07-28 11:56:58 -04:00
end
2009-03-05 16:06:02 -05:00
it 'should only print each format once with an exception' do
2014-12-06 19:12:39 -05:00
expect do
2009-03-05 16:06:02 -05:00
@klass . format :foobar
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: UnsupportedFormat , " ':foobar' Must be one of: csv, html, json, plain, xml " )
2009-03-05 16:06:02 -05:00
end
2009-12-05 21:00:36 -05:00
it 'sets the default parser' do
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :parser ] ) . to be_nil
2009-12-05 21:00:36 -05:00
@klass . format :json
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :parser ] ) . to eq ( HTTParty :: Parser )
2009-12-05 21:00:36 -05:00
end
it 'does not reset parser to the default parser' do
my_parser = lambda { }
@klass . parser my_parser
@klass . format :json
2014-12-06 19:12:39 -05:00
expect ( @klass . parser ) . to eq ( my_parser )
2009-12-05 21:00:36 -05:00
end
2008-07-28 11:56:58 -04:00
end
2008-08-27 16:38:19 -04:00
2010-01-29 16:57:35 -05:00
describe " # no_follow " do
it " sets no_follow to false by default " do
@klass . no_follow
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :no_follow ] ) . to be_falsey
2010-01-29 16:57:35 -05:00
end
it " sets the no_follow option to true " do
@klass . no_follow true
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :no_follow ] ) . to be_truthy
2010-01-29 16:57:35 -05:00
end
end
2010-02-09 22:02:15 -05:00
describe " # maintain_method_across_redirects " do
it " sets maintain_method_across_redirects to true by default " do
@klass . maintain_method_across_redirects
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :maintain_method_across_redirects ] ) . to be_truthy
2010-02-09 22:02:15 -05:00
end
it " sets the maintain_method_across_redirects option to false " do
@klass . maintain_method_across_redirects false
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :maintain_method_across_redirects ] ) . to be_falsey
2010-02-09 22:02:15 -05:00
end
2010-12-10 16:47:42 -05:00
end
2014-12-18 08:28:09 -05:00
2014-07-31 08:18:13 -04:00
describe " # resend_on_redirect " do
it " sets resend_on_redirect to true by default " do
@klass . resend_on_redirect
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :resend_on_redirect ] ) . to be_truthy
2014-07-31 08:18:13 -04:00
end
2014-12-18 08:28:09 -05:00
2014-07-31 08:18:13 -04:00
it " sets resend_on_redirect option to false " do
@klass . resend_on_redirect false
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :resend_on_redirect ] ) . to be_falsey
2014-07-31 08:18:13 -04:00
end
end
2010-12-10 16:47:42 -05:00
2011-01-18 15:36:56 -05:00
describe " .follow_redirects " do
it " sets follow redirects to true by default " do
@klass . follow_redirects
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :follow_redirects ] ) . to be_truthy
2011-01-18 15:36:56 -05:00
end
it " sets the follow_redirects option to false " do
@klass . follow_redirects false
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :follow_redirects ] ) . to be_falsey
2011-01-18 15:36:56 -05:00
end
end
2010-12-10 16:47:42 -05:00
describe " .query_string_normalizer " do
it " sets the query_string_normalizer option " do
normalizer = proc { }
@klass . query_string_normalizer normalizer
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options [ :query_string_normalizer ] ) . to eq ( normalizer )
2010-12-10 16:47:42 -05:00
end
2010-02-09 22:02:15 -05:00
end
2015-12-28 16:14:12 -05:00
describe " .raise_on " do
context 'when parameters is an array' do
it 'sets raise_on option' do
@klass . raise_on [ 500 , 404 ]
expect ( @klass . default_options [ :raise_on ] ) . to contain_exactly ( 404 , 500 )
end
end
context 'when parameters is a fixnum' do
it 'sets raise_on option' do
@klass . raise_on 404
expect ( @klass . default_options [ :raise_on ] ) . to contain_exactly ( 404 )
end
end
end
2008-11-08 13:59:57 -05:00
describe " with explicit override of automatic redirect handling " do
2010-01-29 16:57:35 -05:00
before do
2014-05-15 16:45:32 -04:00
@request = HTTParty :: Request . new ( Net :: HTTP :: Get , 'http://api.foo.com/v1' , format : :xml , no_follow : true )
2010-01-29 16:57:35 -05:00
@redirect = stub_response 'first redirect' , 302
@redirect [ 'location' ] = 'http://foo.com/bar'
2014-12-06 19:12:39 -05:00
allow ( HTTParty :: Request ) . to receive_messages ( new : @request )
2010-01-29 16:57:35 -05:00
end
2008-08-27 16:38:19 -04:00
2008-11-08 13:59:57 -05:00
it " should fail with redirected GET " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@error = @klass . get ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2008-08-27 16:38:19 -04:00
end
2008-09-19 19:31:06 -04:00
2008-11-08 13:59:57 -05:00
it " should fail with redirected POST " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . post ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2008-11-08 13:59:57 -05:00
end
2008-09-19 19:31:06 -04:00
2012-04-13 19:22:51 -04:00
it " should fail with redirected PATCH " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . patch ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2012-04-13 19:22:51 -04:00
end
2008-11-08 13:59:57 -05:00
it " should fail with redirected DELETE " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . delete ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2008-11-08 13:59:57 -05:00
end
2008-09-19 19:31:06 -04:00
2013-01-17 00:01:17 -05:00
it " should fail with redirected MOVE " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . move ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2013-01-17 00:01:17 -05:00
end
2013-02-07 09:34:32 -05:00
it " should fail with redirected COPY " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . copy ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2013-02-07 09:34:32 -05:00
end
2008-11-08 13:59:57 -05:00
it " should fail with redirected PUT " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . put ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2008-09-19 19:31:06 -04:00
end
2009-11-22 23:18:29 -05:00
it " should fail with redirected HEAD " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . head ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2009-11-22 23:18:29 -05:00
end
it " should fail with redirected OPTIONS " do
2014-12-06 19:12:39 -05:00
expect do
2014-05-15 16:45:32 -04:00
@klass . options ( '/foo' , no_follow : true )
2014-12-06 19:12:39 -05:00
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
2009-11-22 23:18:29 -05:00
end
2016-03-11 02:43:38 -05:00
it " should fail with redirected MKCOL " do
expect do
@klass . mkcol ( '/foo' , no_follow : true )
end . to raise_error ( HTTParty :: RedirectionTooDeep ) { | e | expect ( e . response . body ) . to eq ( 'first redirect' ) }
end
2008-07-28 13:32:35 -04:00
end
2009-09-08 23:34:21 -04:00
2015-08-22 14:03:18 -04:00
describe " head requests should follow redirects requesting HEAD only " do
before do
2015-08-24 18:46:47 -04:00
allow ( HTTParty :: Request ) . to receive ( :new ) .
and_return ( double ( " mock response " , perform : nil ) )
end
it " should remain HEAD request across redirects, unless specified otherwise " do
expect ( @klass ) . to receive ( :ensure_method_maintained_across_redirects ) . with ( { } )
@klass . head ( '/foo' )
2015-08-22 14:03:18 -04:00
end
2015-08-24 18:46:47 -04:00
end
describe " # ensure_method_maintained_across_redirects " do
2015-08-22 14:03:18 -04:00
it " should set maintain_method_across_redirects option if unspecified " do
2015-08-24 18:46:47 -04:00
options = { }
@klass . send ( :ensure_method_maintained_across_redirects , options )
expect ( options [ :maintain_method_across_redirects ] ) . to be_truthy
end
2015-08-22 14:03:18 -04:00
2015-08-24 18:46:47 -04:00
it " should not set maintain_method_across_redirects option if value is present " do
options = { maintain_method_across_redirects : false }
@klass . send ( :ensure_method_maintained_across_redirects , options )
expect ( options [ :maintain_method_across_redirects ] ) . to be_falsey
2015-08-22 14:03:18 -04:00
end
end
2008-11-30 23:58:06 -05:00
describe " with multiple class definitions " do
2009-01-28 23:41:01 -05:00
before ( :each ) do
@klass . instance_eval do
base_uri " http://first.com "
2014-05-15 16:45:32 -04:00
default_params one : 1
2009-01-28 23:41:01 -05:00
end
@additional_klass = Class . new
@additional_klass . instance_eval do
include HTTParty
base_uri " http://second.com "
2014-05-15 16:45:32 -04:00
default_params two : 2
2009-01-28 23:41:01 -05:00
end
end
2008-11-30 23:58:06 -05:00
it " should not run over each others options " do
2014-12-06 19:12:39 -05:00
expect ( @klass . default_options ) . to eq ( { base_uri : 'http://first.com' , default_params : { one : 1 } } )
expect ( @additional_klass . default_options ) . to eq ( { base_uri : 'http://second.com' , default_params : { two : 2 } } )
2008-11-30 23:58:06 -05:00
end
end
2009-09-08 23:34:21 -04:00
2009-11-24 17:22:45 -05:00
describe " two child classes inheriting from one parent " do
before ( :each ) do
@parent = Class . new do
include HTTParty
2010-07-07 08:55:51 -04:00
def self . name
" Parent "
end
2009-11-24 17:22:45 -05:00
end
@child1 = Class . new ( @parent )
@child2 = Class . new ( @parent )
end
it " does not modify each others inherited attributes " do
2014-05-15 16:45:32 -04:00
@child1 . default_params joe : " alive "
@child2 . default_params joe : " dead "
2009-11-24 17:22:45 -05:00
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options ) . to eq ( { default_params : { joe : " alive " } } )
expect ( @child2 . default_options ) . to eq ( { default_params : { joe : " dead " } } )
2009-11-24 17:22:45 -05:00
2014-12-06 19:12:39 -05:00
expect ( @parent . default_options ) . to eq ( { } )
2009-11-24 17:22:45 -05:00
end
2010-07-07 09:43:38 -04:00
it " inherits default_options from the superclass " do
@parent . basic_auth 'user' , 'password'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options ) . to eq ( { basic_auth : { username : 'user' , password : 'password' } } )
2010-07-07 09:43:38 -04:00
@child1 . basic_auth 'u' , 'p' # modifying child1 has no effect on child2
2014-12-06 19:12:39 -05:00
expect ( @child2 . default_options ) . to eq ( { basic_auth : { username : 'user' , password : 'password' } } )
2010-07-07 09:43:38 -04:00
end
it " doesn't modify the parent's default options " do
@parent . basic_auth 'user' , 'password'
@child1 . basic_auth 'u' , 'p'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options ) . to eq ( { basic_auth : { username : 'u' , password : 'p' } } )
2010-07-07 09:43:38 -04:00
@child1 . basic_auth 'email' , 'token'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options ) . to eq ( { basic_auth : { username : 'email' , password : 'token' } } )
2010-07-07 09:43:38 -04:00
2014-12-06 19:12:39 -05:00
expect ( @parent . default_options ) . to eq ( { basic_auth : { username : 'user' , password : 'password' } } )
2010-07-07 09:43:38 -04:00
end
2012-04-21 18:45:03 -04:00
it " doesn't modify hashes in the parent's default options " do
@parent . headers 'Accept' = > 'application/json'
@child1 . headers 'Accept' = > 'application/xml'
2014-12-06 19:12:39 -05:00
expect ( @parent . default_options [ :headers ] ) . to eq ( { 'Accept' = > 'application/json' } )
expect ( @child1 . default_options [ :headers ] ) . to eq ( { 'Accept' = > 'application/xml' } )
2012-04-21 18:45:03 -04:00
end
2013-01-01 13:48:32 -05:00
it " works with lambda values " do
@child1 . default_options [ :imaginary_option ] = lambda { " This is a new lambda " }
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options [ :imaginary_option ] ) . to be_a Proc
2013-01-01 13:48:32 -05:00
end
it 'should dup the proc on the child class' do
2013-03-25 10:50:30 -04:00
imaginary_option = lambda { 2 * 3 . 14 }
2013-01-01 13:48:32 -05:00
@parent . default_options [ :imaginary_option ] = imaginary_option
2014-12-06 19:12:39 -05:00
expect ( @parent . default_options [ :imaginary_option ] . call ) . to eq ( imaginary_option . call )
2013-01-01 13:48:32 -05:00
@child1 . default_options [ :imaginary_option ]
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_options [ :imaginary_option ] . call ) . to eq ( imaginary_option . call )
expect ( @child1 . default_options [ :imaginary_option ] ) . not_to be_equal imaginary_option
2013-01-01 13:48:32 -05:00
end
2010-07-07 09:43:38 -04:00
it " inherits default_cookies from the parent class " do
@parent . cookies 'type' = > 'chocolate_chip'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_cookies ) . to eq ( { " type " = > " chocolate_chip " } )
2010-07-07 09:43:38 -04:00
@child1 . cookies 'type' = > 'snickerdoodle'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_cookies ) . to eq ( { " type " = > " snickerdoodle " } )
expect ( @child2 . default_cookies ) . to eq ( { " type " = > " chocolate_chip " } )
2010-07-07 09:43:38 -04:00
end
it " doesn't modify the parent's default cookies " do
@parent . cookies 'type' = > 'chocolate_chip'
@child1 . cookies 'type' = > 'snickerdoodle'
2014-12-06 19:12:39 -05:00
expect ( @child1 . default_cookies ) . to eq ( { " type " = > " snickerdoodle " } )
2010-07-07 09:43:38 -04:00
2014-12-06 19:12:39 -05:00
expect ( @parent . default_cookies ) . to eq ( { " type " = > " chocolate_chip " } )
2010-07-07 09:43:38 -04:00
end
2009-11-24 17:22:45 -05:00
end
2010-07-07 11:26:20 -04:00
describe " grand parent with inherited callback " do
before do
@grand_parent = Class . new do
def self . inherited ( subclass )
subclass . instance_variable_set ( :@grand_parent , true )
end
end
@parent = Class . new ( @grand_parent ) do
include HTTParty
end
end
it " continues running the # inherited on the parent " do
child = Class . new ( @parent )
2014-12-06 19:12:39 -05:00
expect ( child . instance_variable_get ( :@grand_parent ) ) . to be_truthy
2010-07-07 11:26:20 -04:00
end
end
2008-12-06 19:41:23 -05:00
describe " # get " do
it " should be able to get html " do
stub_http_response_with ( 'google.html' )
2014-12-09 00:01:13 -05:00
expect ( HTTParty . get ( 'http://www.google.com' ) . parsed_response ) . to eq ( file_fixture ( 'google.html' ) )
2008-12-06 19:41:23 -05:00
end
2009-09-08 23:34:21 -04:00
2012-02-15 14:46:01 -05:00
it " should be able to get chunked html " do
2015-04-17 19:39:52 -04:00
chunks = %w( Chunk1 Chunk2 Chunk3 Chunk4 )
2012-02-15 14:46:01 -05:00
stub_chunked_http_response_with ( chunks )
2014-12-06 20:37:34 -05:00
expect (
HTTParty . get ( 'http://www.google.com' ) do | fragment |
expect ( chunks ) . to include ( fragment )
2014-12-06 20:48:53 -05:00
end . parsed_response
2014-12-06 20:37:34 -05:00
) . to eq ( chunks . join )
2012-02-15 14:46:01 -05:00
end
2014-11-03 15:53:06 -05:00
it " should return an empty body if stream_body option is turned on " do
2015-04-17 19:39:52 -04:00
chunks = %w( Chunk1 Chunk2 Chunk3 Chunk4 )
2014-11-03 15:53:06 -05:00
options = { stream_body : true , format : 'html' }
stub_chunked_http_response_with ( chunks , options )
2014-12-06 20:37:34 -05:00
expect (
HTTParty . get ( 'http://www.google.com' , options ) do | fragment |
expect ( chunks ) . to include ( fragment )
2014-12-06 20:48:53 -05:00
end . parsed_response
2014-12-06 20:37:34 -05:00
) . to eq ( nil )
2014-11-03 15:53:06 -05:00
end
2008-12-06 19:41:23 -05:00
it " should be able parse response type json automatically " do
stub_http_response_with ( 'twitter.json' )
tweets = HTTParty . get ( 'http://twitter.com/statuses/public_timeline.json' )
2014-12-06 19:12:39 -05:00
expect ( tweets . size ) . to eq ( 20 )
expect ( tweets . first [ 'user' ] ) . to eq ( {
2009-09-08 23:34:21 -04:00
" name " = > " Pyk " ,
" url " = > nil ,
" id " = > " 7694602 " ,
" description " = > nil ,
" protected " = > false ,
" screen_name " = > " Pyk " ,
" followers_count " = > 1 ,
" location " = > " Opera Plaza, California " ,
2008-12-06 19:41:23 -05:00
" profile_image_url " = > " http://static.twitter.com/images/default_profile_normal.png "
2014-12-06 19:12:39 -05:00
} )
2008-12-06 19:41:23 -05:00
end
2009-09-08 23:34:21 -04:00
2008-12-06 19:41:23 -05:00
it " should be able parse response type xml automatically " do
stub_http_response_with ( 'twitter.xml' )
tweets = HTTParty . get ( 'http://twitter.com/statuses/public_timeline.xml' )
2014-12-06 19:12:39 -05:00
expect ( tweets [ 'statuses' ] . size ) . to eq ( 20 )
expect ( tweets [ 'statuses' ] . first [ 'user' ] ) . to eq ( {
2009-09-08 23:34:21 -04:00
" name " = > " Magic 8 Bot " ,
" url " = > nil ,
" id " = > " 17656026 " ,
" description " = > " ask me a question " ,
" protected " = > " false " ,
" screen_name " = > " magic8bot " ,
" followers_count " = > " 90 " ,
" profile_image_url " = > " http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg " ,
2008-12-06 19:41:23 -05:00
" location " = > nil
2014-12-06 19:12:39 -05:00
} )
2008-12-06 19:41:23 -05:00
end
2009-09-08 23:34:21 -04:00
2014-02-08 12:32:43 -05:00
it " should be able parse response type csv automatically " do
stub_http_response_with ( 'twitter.csv' )
profile = HTTParty . get ( 'http://twitter.com/statuses/profile.csv' )
2014-12-06 19:12:39 -05:00
expect ( profile . size ) . to eq ( 2 )
2015-04-17 19:39:52 -04:00
expect ( profile [ 0 ] ) . to eq ( %w( name url id description protected screen_name followers_count profile_image_url location ) )
2015-04-18 06:29:00 -04:00
expect ( profile [ 1 ] ) . to eq ( [ " Magic 8 Bot " , nil , " 17656026 " , " ask me a question " , " false " , " magic8bot " , " 90 " , " http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg " , nil ] )
2014-02-08 12:32:43 -05:00
end
2009-01-28 12:55:25 -05:00
it " should not get undefined method add_node for nil class for the following xml " do
stub_http_response_with ( 'undefined_method_add_node_for_nil.xml' )
result = HTTParty . get ( 'http://foobar.com' )
2015-04-17 20:04:14 -04:00
expect ( result . parsed_response ) . to eq ( { " Entities " = > { " href " = > " https://s3-sandbox.parature.com/api/v1/5578/5633/Account " , " results " = > " 0 " , " total " = > " 0 " , " page_size " = > " 25 " , " page " = > " 1 " } } )
2009-01-28 12:55:25 -05:00
end
2009-09-08 23:34:21 -04:00
2009-01-28 13:17:39 -05:00
it " should parse empty response fine " do
stub_http_response_with ( 'empty.xml' )
result = HTTParty . get ( 'http://foobar.com' )
2014-12-06 19:12:39 -05:00
expect ( result ) . to be_nil
2009-01-28 13:17:39 -05:00
end
2009-10-28 17:39:14 -04:00
it " should accept http URIs " do
stub_http_response_with ( 'google.html' )
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty . get ( 'http://google.com' )
2014-12-06 19:12:39 -05:00
end . not_to raise_error
2009-10-28 17:39:14 -04:00
end
it " should accept https URIs " do
stub_http_response_with ( 'google.html' )
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty . get ( 'https://google.com' )
2014-12-06 19:12:39 -05:00
end . not_to raise_error
2009-10-28 17:39:14 -04:00
end
2012-09-17 15:33:00 -04:00
it " should accept webcal URIs " do
2015-05-31 12:28:32 -04:00
uri = 'http://google.com/'
FakeWeb . register_uri ( :get , uri , body : 'stuff' )
uri = 'webcal://google.com/'
2014-12-06 19:12:39 -05:00
expect do
2015-05-31 12:28:32 -04:00
HTTParty . get ( uri )
2014-12-06 19:12:39 -05:00
end . not_to raise_error
2009-10-28 17:39:14 -04:00
end
it " should raise an InvalidURIError on URIs that can't be parsed at all " do
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty . get ( " It's the one that says 'Bad URI' " )
2014-12-06 19:12:39 -05:00
end . to raise_error ( URI :: InvalidURIError )
2009-10-28 17:39:14 -04:00
end
2008-12-06 19:41:23 -05:00
end
2009-09-08 23:34:21 -04:00
end