blob: d79b17b932bc3c08f73be6593885f8e8f905c57b (
plain) (
blame)
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
|
require 'abstract_unit'
class StringCoercionTest < ActiveSupport::TestCase
test "body responds to each" do
original_body = []
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
assert original_body.respond_to?(:each)
assert body.respond_to?(:each)
end
test "body responds to to_path" do
original_body = []
def original_body.to_path; end
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
assert original_body.respond_to?(:to_path)
assert body.respond_to?(:to_path)
end
test "body does not responds to to_path" do
original_body = []
body = ActionDispatch::StringCoercion::UglyBody.new(original_body)
assert !original_body.respond_to?(:to_path)
assert !body.respond_to?(:to_path)
end
test "calls to_s on body parts" do
app = lambda { |env|
[200, {'Content-Type' => 'html'}, [1, 2, 3]]
}
app = ActionDispatch::StringCoercion.new(app)
parts = []
status, headers, body = app.call({})
body.each { |part| parts << part }
assert_equal %w( 1 2 3 ), parts
end
end
|