Skip to content

Commit

Permalink
Test respond_to? :to_ary directly on RackBody
Browse files Browse the repository at this point in the history
RackBody is the final body object returned by the Rack app
(`Rails.application`). This test that it conforms to the spec
instead of testing on the underlying response.
  • Loading branch information
JoeDupuis committed Jun 12, 2023
1 parent 0174283 commit 7c3fc67
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions actionpack/test/controller/live_stream_test.rb
Expand Up @@ -319,11 +319,6 @@ def ignore_client_disconnect
logger.info "Work complete"
latch.count_down
end

def buffer_do_not_respond_to_to_ary
response.stream.write "response.stream.respond_to? = #{response.stream.respond_to?(:to_ary)}"
response.stream.close
end
end

tests TestController
Expand Down Expand Up @@ -603,8 +598,13 @@ def test_stale_with_etag
end

def test_response_buffer_do_not_respond_to_to_ary
get :buffer_do_not_respond_to_to_ary
assert_equal "response.stream.respond_to? = false", response.body
get :basic_stream
# `response.to_a` wraps the response with RackBody.
# RackBody is the body we return to Rack.
# Therefore we want to assert directly on it.
# The Rack spec requires bodies that cannot be
# buffered to return false to `respond_to?(:to_ary)`
assert_not response.to_a.last.respond_to? :to_ary
end
end

Expand Down

0 comments on commit 7c3fc67

Please sign in to comment.