如何在Rspec中的控制台输出测试之间添加换行符?

时间:2017-06-22 09:08:17

标签: ruby-on-rails rspec

我有几个使用Rspec运行的测试。

输出如下所示:

returns an array containing partial words that have changed their case(upper/lower), 
and have matching partial words in opposite elements(ins/del)
returns an array containing words that have changed their case(upper/lower),
and have matching whole words in opposite elements(ins/del)
returns an array containing words that have changed their case(upper/lower), are at the start of a sentence, 
and have matching words in opposite elements(ins/del)
returns an array containing partial words that have changed their case(uppler/lower), have matching partial words in opposite elements(ins/del), 
and are preceded by an inserted word

我希望每个测试都用换行符分隔,以便我更容易阅读输出。我尝试添加“\ n”,但它似乎无法正常工作。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

你可以使用ruby输出命令print或puts来测试之间的换行 print和puts之间的区别,print不会自动提供换行但是puts会自动给出 下面是示例代码

print "test = ", variable , ".\n"
puts  "test = ", variable

上面的两个命令都会在每个命令执行后给出换行符