Skip to content

Commit

Permalink
ensure no regex warnings about UTF-8 strings
Browse files Browse the repository at this point in the history
This is a cherry-pick of 3dddbfc

References lostisland#95
  • Loading branch information
mislav committed Jan 2, 2012
1 parent a81b705 commit c78cb61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'test/unit'
require 'stringio'

if ENV['LEFTRIGHT']
begin
Expand Down Expand Up @@ -29,6 +30,16 @@ class TestCase < Test::Unit::TestCase
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

Expand Down
9 changes: 9 additions & 0 deletions test/request_middleware_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

Faraday::CompositeReadIO.send :attr_reader, :ios
Expand Down Expand Up @@ -47,6 +48,14 @@ def test_url_encoded_nested
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 = [
Expand Down

0 comments on commit c78cb61

Please sign in to comment.