test/request_test.rb in sinatra-1.4.5 vs test/request_test.rb in sinatra-1.4.6
- old
+ new
@@ -1,9 +1,9 @@
require File.expand_path('../helper', __FILE__)
require 'stringio'
-class RequestTest < Test::Unit::TestCase
+class RequestTest < Minitest::Test
it 'responds to #user_agent' do
request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'})
assert request.respond_to?(:user_agent)
assert_equal 'Test', request.user_agent
end
@@ -52,10 +52,11 @@
it "makes accept types behave like strings" do
request = Sinatra::Request.new('HTTP_ACCEPT' => 'image/jpeg; compress=0.25')
assert request.accept?('image/jpeg')
assert_equal 'image/jpeg', request.preferred_type.to_s
+ assert_equal 'image/jpeg; compress=0.25', request.preferred_type.to_s(true)
assert_equal 'image/jpeg', request.preferred_type.to_str
assert_equal 'image', request.preferred_type.split('/').first
String.instance_methods.each do |method|
next unless "".respond_to? method
@@ -79,16 +80,18 @@
it 'accepts */* when HTTP_ACCEPT is not present in the request' do
request = Sinatra::Request.new Hash.new
assert_equal 1, request.accept.size
assert request.accept?('text/html')
assert_equal '*/*', request.preferred_type.to_s
+ assert_equal '*/*', request.preferred_type.to_s(true)
end
it 'accepts */* when HTTP_ACCEPT is blank in the request' do
request = Sinatra::Request.new 'HTTP_ACCEPT' => ''
assert_equal 1, request.accept.size
assert request.accept?('text/html')
assert_equal '*/*', request.preferred_type.to_s
+ assert_equal '*/*', request.preferred_type.to_s(true)
end
it 'will not accept types not specified in HTTP_ACCEPT when HTTP_ACCEPT is provided' do
request = Sinatra::Request.new 'HTTP_ACCEPT' => 'application/json'
assert !request.accept?('text/html')