-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.rb
More file actions
executable file
·76 lines (63 loc) · 1.51 KB
/
Copy pathtest.rb
File metadata and controls
executable file
·76 lines (63 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
# gem "rack", "~> 3.0.0"
# gem "rack", "~> 3.1.0"
gem "rack", path: "."
end
require "action_controller/railtie"
class TestApp < Rails::Application
config.root = __dir__
config.hosts << "www.example.com"
config.secret_key_base = "secret_key_base"
config.action_dispatch.show_exceptions = :rescuable
config.logger = Logger.new($stdout)
Rails.logger = config.logger
routes.draw do
get "/head" => "test#one"
get "/empty" => "test#two"
get "/body" => "test#three"
end
end
class TestController < ActionController::Base
def one
head 200
end
def two
render plain: ''
end
def three
render plain: 'a', layout: false
end
end
require "minitest/autorun"
class TestControllerTest < ActionDispatch::IntegrationTest
# works on rack 3.0
# content-length key is missing on rack 3.1
def test_head
get "/head"
assert_response 200
assert_equal '0', headers['content-length']
# assert headers.key?('content-length')
end
# works on rack 3.0
# content-length key is missing on rack 3.1
def test_empty_body
get "/empty"
assert_response 200
assert_equal '0', headers['content-length']
# assert headers.key?('content-length')
end
# works on rack 3.0 and 3.1
def test_with_body
get "/body"
assert_response 200
assert_equal '1', headers['content-length']
end
private
def app
Rails.application
end
end