如何在 Cucumber 报告中换行一段?

How can I wrap a paragraph on a Cucumber report?

如何在 Cucumber 报告中换行一段?

我有一个 Cucumber 报告,我正在使用以下方法在报告上打印文本:

puts "whatever i want to say"

如果该字符串很长,该段落不会在 HTML 报告中换行。有什么方法可以让 puts 输出在输出很长时换行?

我用这个在报告上打印:

Then(/^show me the api response$/) do
  unless @response
    @response = 'null'
  end
  puts "res: <br/><div style=\"div {word-break: break-all;}\">" + @response.to_s + "</div>"
end

更新 谢谢你的回答。这是我的最终代码:

Then(/^show me the entire api response$/) do
  unless @response
    @response = 'null'
  end
  puts "API RESPONSE: " + @response.to_s.scan(/.{1,160}/).join("\n")
end
puts <any_long_value>.to_s.scan(/.{1,256}/).join("\n") 

其中 1,256 定义了换行前所需的字符数 (256)。