test/excon/addressable_test.rb in excon-addressable-0.3.1 vs test/excon/addressable_test.rb in excon-addressable-0.4.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+
require_relative '../test_helper'
module Excon
# AddressableTest
#
@@ -11,10 +12,11 @@
Excon.defaults[:middlewares].unshift(Excon::Addressable::Middleware)
Excon.defaults[:mock] = true
Excon.stub({ path: '/' }, body: 'index')
Excon.stub({ path: '/hello' }, body: 'world')
Excon.stub({ path: '/hello', query: 'message=world' }, body: 'hi!')
+ Excon.stub({ path: '/hello', query: 'a=b&c=d' }, body: 'earth')
Excon.stub({ path: '/world' }, body: 'universe')
end
def test_expand_templated_uri
connection = Excon.new('http://www.example.com/{uid}', expand: { uid: 'hello' })
@@ -46,9 +48,27 @@
def test_templated_uri_overriding_variables
connection = Excon.new('http://www.example.com/{uid}{?message}', expand: { uid: 'goodbye' })
response = connection.get(expand: { uid: 'hello', message: 'world' })
assert_equal 'hi!', response.body
+ end
+
+ def test_uri_with_full_uri
+ response = Excon.get('http://www.example.com/hello?message=world')
+
+ assert_equal 'hi!', response.body
+ end
+
+ def test_uri_with_query
+ response = Excon.get('http://www.example.com/hello', query: { message: 'world' })
+
+ assert_equal 'hi!', response.body
+ end
+
+ def test_uri_with_multiple_queries
+ response = Excon.get('https://www.example.com/hello', query: { a: 'b', c: 'd' })
+
+ assert_equal 'earth', response.body
end
def teardown
Excon.stubs.clear
end