spec/hyperdrive/middleware/charset_spec.rb in hyperdrive-0.0.22 vs spec/hyperdrive/middleware/charset_spec.rb in hyperdrive-0.0.23
- old
+ new
@@ -1,11 +1,10 @@
# encoding: utf-8
require 'spec_helper'
describe Hyperdrive::Middleware::Charset do
-
def app
inner_app = ->(env) { [200, {}, [env['hyperdrive.params']]] }
Hyperdrive::Middleware::Charset.new(inner_app)
end
@@ -14,9 +13,15 @@
@env.merge!('REQUEST_METHOD' => 'POST')
@params = { id: '1001', name: 'John Connor'.encode('ASCII-8BIT') }
end
it "will enforce accept-charset encoding on param values" do
+ post '/', @params, @env.merge('hyperdrive.params' => @params)
+ last_response.body.must_equal "{:id=>\"1001\", :name=>\"John Connor\"}"
+ end
+
+ it "will enforce a default charset if accept-charset is not present" do
+ @env.delete('HTTP_ACCEPT_CHARSET')
post '/', @params, @env.merge('hyperdrive.params' => @params)
last_response.body.must_equal "{:id=>\"1001\", :name=>\"John Connor\"}"
end
end