summary refs log tree commit
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2017-05-16 15:46:54 -0400
committereileencodes <eileencodes@gmail.com>2017-05-16 15:46:54 -0400
commitb62cd8a33032107e181286c33d8e385111d8e49d (patch)
treeacbf5d682cc222cd42ff3c7b3dfc97c43c5a8339
parent51e8891e4807495d972fcba9832c4fdb30d37b50 (diff)
downloadrack-b62cd8a33032107e181286c33d8e385111d8e49d.tar.gz
Fix mistake in encoding change
1) I wasn't even testing my change on the branches I made changes on
because I accidentally used `unless` instead of `if`. This test should
only run IF encoding them to binary is supported. :flushed:

2) 1.9.3 does respond to `:encoding` but it doesn't respond to `:b` and
since it's `:b` we're calling on these env vars it's best to ask if it
responds to that method, not to `:encoding`.

Fixes #1168
-rw-r--r--lib/rack/mock.rb2
-rw-r--r--test/spec_mock.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb
index 6a0b7208..1a1add2f 100644
--- a/lib/rack/mock.rb
+++ b/lib/rack/mock.rb
@@ -143,7 +143,7 @@ module Rack
       env
     end
 
-    if "<3".respond_to? :encoding
+    if "<3".respond_to? :b
       def self.env_with_encoding(env, opts, uri)
         env[REQUEST_METHOD] = (opts[:method] ? opts[:method].to_s.upcase : "GET").b
         env["SERVER_NAME"] = (uri.host || "example.org").b
diff --git a/test/spec_mock.rb b/test/spec_mock.rb
index 1bb22974..8132e9b3 100644
--- a/test/spec_mock.rb
+++ b/test/spec_mock.rb
@@ -212,7 +212,7 @@ describe Rack::MockRequest do
     called.should.equal true
   end
 
-  unless "<3".respond_to? :encoding
+  if "<3".respond_to? :b
     should "defaults encoding to ASCII 8BIT" do
       req = Rack::MockRequest.env_for("/foo")