From b62cd8a33032107e181286c33d8e385111d8e49d Mon Sep 17 00:00:00 2001 From: eileencodes Date: Tue, 16 May 2017 15:46:54 -0400 Subject: 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 --- lib/rack/mock.rb | 2 +- test/spec_mock.rb | 2 +- 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") -- cgit v1.2.3-24-ge0c7