如何在黄瓜报告上包含一个段落?

时间:2016-10-07 20:54:47

标签: 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

1 个答案:

答案 0 :(得分:1)

puts <any_long_value>.to_s.scan(/.{1,256}/).join("\n") 

其中1,256定义了包装前所需字符的数量(256)。