Permalink
Browse files

Remove to_binary, closes #243 and #340

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
  • Loading branch information...
1 parent 5450b0a commit aeb62d60634a1ed0b25afe278c32ccce64ee708b @jnicklas committed May 19, 2011
Showing with 1 addition and 38 deletions.
  1. +1 −15 lib/capybara/rack_test/browser.rb
  2. +0 −23 spec/driver/rack_test_driver_spec.rb
View
16 lib/capybara/rack_test/browser.rb
@@ -43,7 +43,7 @@ def process(method, path, attributes = {})
end
reset_cache!
- send(method, to_binary(path), to_binary( attributes ), env)
+ send(method, path, attributes, env)
follow_redirects!
end
@@ -85,20 +85,6 @@ def build_rack_mock_session
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
View
23 spec/driver/rack_test_driver_spec.rb
@@ -25,29 +25,6 @@ def capture(*streams)
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"

0 comments on commit aeb62d6

Please sign in to comment.