当我使用 rake rspec
运行 rspec
并且我的测试不正常时,我收到一条错误消息。但是,当我的测试正常时,我只会得到“..”。没有其他输出。我怎样才能让它打印出类似的东西:
A User .... can only have one name
A User .... can ...
从 rspec
帮助页面
$ rspec --help
Usage: rspec [options] [files or directories]
-f, --format FORMATTER Choose a formatter
[p]rogress (default - dots)
[d]ocumentation (group and example names)
[h]tml
[t]extmate
custom formatter class name
传递 -f
参数。代替
$ rake rspec
跑
$ rspec spec --format d
或短格式:
$ rspec -fd
如果您希望配置永久有效,请在项目的根目录中创建一个 .rspec
文件并将配置写入其中。
在您的 spec/spec_helper
内
RSpec.configure do |config|
config.formatter = :documentation
end
所以你不必每次都运行标志。
利用:
rspec spec --format documentation
.rspec
文件中。我有--color --tty --format documentation
(每行一个 --option )。