mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
After investigating this thoroughly, I have come to the conclusion that the need for to_binary came from a bug in rack, which has subsequently been fixed. If warnings show up after this change they should disappear with the release of rack 1.3
This commit is contained in:
parent
5450b0a17e
commit
aeb62d6063
2 changed files with 1 additions and 38 deletions
|
@ -43,7 +43,7 @@ class Capybara::RackTest::Browser
|
|||
end
|
||||
|
||||
reset_cache!
|
||||
send(method, to_binary(path), to_binary( attributes ), env)
|
||||
send(method, path, attributes, env)
|
||||
follow_redirects!
|
||||
end
|
||||
|
||||
|
@ -85,20 +85,6 @@ protected
|
|||
Rack::MockSession.new(app, current_host)
|
||||
end
|
||||
|
||||
def to_binary(object)
|
||||
return object unless Kernel.const_defined?(:Encoding)
|
||||
|
||||
if object.respond_to?(:force_encoding)
|
||||
object.dup.force_encoding(Encoding::ASCII_8BIT)
|
||||
elsif object.respond_to?(:each_pair) #Hash
|
||||
{}.tap { |x| object.each_pair {|k,v| x[to_binary(k)] = to_binary(v) } }
|
||||
elsif object.respond_to?(:each) #Array
|
||||
object.map{|x| to_binary(x)}
|
||||
else
|
||||
object
|
||||
end
|
||||
end
|
||||
|
||||
def request_path
|
||||
last_request.path
|
||||
rescue Rack::Test::Error
|
||||
|
|
|
@ -25,29 +25,6 @@ describe Capybara::RackTest::Driver do
|
|||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
if '1.9'.respond_to?(:encode)
|
||||
describe "with non-binary parameters" do
|
||||
|
||||
it "should convert attribute values to binary" do
|
||||
output = capture(:stderr) {
|
||||
@driver.visit('/mypage', :param => 'µ')
|
||||
}.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
|
||||
end
|
||||
|
||||
it "should convert attribute with Array to binary" do
|
||||
output = capture(:stderr) {
|
||||
@driver.visit('/mypage', :param => ['µ'])
|
||||
}.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
|
||||
end
|
||||
|
||||
it "should convert path to binary" do
|
||||
output = capture(:stderr) {
|
||||
@driver.visit('/mypage'.encode('utf-8'))
|
||||
}.should_not =~ %r{warning: regexp match /.../n against to UTF-8 string}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_should_behave_like "driver"
|
||||
it_should_behave_like "driver with header support"
|
||||
it_should_behave_like "driver with status code support"
|
||||
|
|
Loading…
Add table
Reference in a new issue