From c78cb61ef1898cc35c465ce2cfd7e7abdd700e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohnic=CC=81?= Date: Mon, 2 Jan 2012 18:59:36 +0100 Subject: [PATCH] ensure no regex warnings about UTF-8 strings This is a cherry-pick of 3dddbfcd776930910d065744517394565339ec2f References #95 --- test/helper.rb | 11 +++++++++++ test/request_middleware_test.rb | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/test/helper.rb b/test/helper.rb index c91da680..19d2f438 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'stringio' if ENV['LEFTRIGHT'] begin @@ -29,6 +30,16 @@ module Faraday def test_default assert true end unless defined? ::MiniTest + + def capture_warnings + old, $stderr = $stderr, StringIO.new + begin + yield + $stderr.string + ensure + $stderr = old + end + end end end diff --git a/test/request_middleware_test.rb b/test/request_middleware_test.rb index 12a99656..84d27c4e 100644 --- a/test/request_middleware_test.rb +++ b/test/request_middleware_test.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) Faraday::CompositeReadIO.send :attr_reader, :ios @@ -47,6 +48,14 @@ class RequestMiddlewareTest < Faraday::TestCase assert_equal expected, Faraday::Utils.parse_nested_query(response.body) end + def test_url_encoded_unicode + err = capture_warnings { + response = @conn.post('/echo', {:str => "eé cç aã aâ"}) + assert_equal "str=e%C3%A9+c%C3%A7+a%C3%A3+a%C3%A2", response.body + } + assert err.empty? + end + def test_multipart # assume params are out of order regexes = [