Methods
- S
- T
-
- test_can_wait_until_commit,
- test_each_isnt_called_if_str_body_is_written,
- test_only_set_charset_still_defaults_to_text_html,
- test_read_body_during_action,
- test_response_body_encoding,
- test_response_charset_writer,
- test_set_header_after_read_body_during_action,
- test_setting_content_type_header_impacts_content_type_method,
- test_stream_close,
- test_stream_write,
- test_write_after_close
Instance Public methods
setup()
Link
test_can_wait_until_commit()
Link
test_each_isnt_called_if_str_body_is_written()
Link
# File actionpack/test/dispatch/response_test.rb, line 40 def test_each_isnt_called_if_str_body_is_written # Controller writes and reads response body each_counter = 0 @response.body = Object.new.tap {|o| o.singleton_class.send(:define_method, :each) { |&block| each_counter += 1; block.call 'foo' } } @response['X-Foo'] = @response.body assert_equal 1, each_counter, "#each was not called once" # Build response status, headers, body = @response.to_a assert_equal 200, status assert_equal "foo", headers['X-Foo'] assert_equal "foo", body.each.to_a.join # Show that #each was not called twice assert_equal 1, each_counter, "#each was not called once" end
test_only_set_charset_still_defaults_to_text_html()
Link
# File actionpack/test/dispatch/response_test.rb, line 131 def test_only_set_charset_still_defaults_to_text_html response = ActionDispatch::Response.new response.charset = "utf-16" _,headers,_ = response.to_a assert_equal "text/html; charset=utf-16", headers['Content-Type'] end
test_read_body_during_action()
Link
# File actionpack/test/dispatch/response_test.rb, line 73 def test_read_body_during_action @response.body = "Hello, World!" # even though there's no explicitly set content-type, assert_equal nil, @response.content_type # after the action reads back @response.body, assert_equal "Hello, World!", @response.body # the response can be built. status, headers, body = @response.to_a assert_equal 200, status assert_equal({ "Content-Type" => "text/html; charset=utf-8" }, headers) parts = [] body.each { |part| parts << part } assert_equal ["Hello, World!"], parts end
test_response_body_encoding()
Link
# File actionpack/test/dispatch/response_test.rb, line 94 def test_response_body_encoding body = ["hello".encode(Encoding::UTF_8)] response = ActionDispatch::Response.new 200, {}, body response.request = ActionDispatch::Request.empty assert_equal Encoding::UTF_8, response.body.encoding end
test_response_charset_writer()
Link
test_set_header_after_read_body_during_action()
Link
# File actionpack/test/dispatch/response_test.rb, line 59 def test_set_header_after_read_body_during_action @response.body # set header after the action reads back @response.body @response['x-header'] = "Best of all possible worlds." # the response can be built. status, headers, body = @response.to_a assert_equal 200, status assert_equal "", body.body assert_equal "Best of all possible worlds.", headers['x-header'] end
test_setting_content_type_header_impacts_content_type_method()
Link
test_stream_close()
Link
test_stream_write()
Link