Ruby-on-rails Rspec 输出格式:文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5083804/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rspec Output Format: Documentation
提问by Spyros
When I run rspecwith rake rspecand my tests are not ok, I get an error message. However, when my tests are ok, I just get '..'. No other output. How can I get it to print something like:
当我运行rspec与rake rspec和我的测试是不正常的,我得到一个错误信息。但是,当我的测试没问题时,我只会得到“..”。没有其他输出。我怎样才能让它打印出类似的东西:
A User .... can only have one name
A User .... can ...
回答by Simone Carletti
From the rspechelp page
从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
Pass the -fparameter. Instead of
传递-f参数。代替
$ rake rspec
run
跑
$ rspec spec --format d
or short format:
或短格式:
$ rspec -fd
If you want the configuration to be permanent, create a .rspecfile in the root of your project and write there the configurations.
如果您希望配置是永久性的,请.rspec在项目的根目录中创建一个文件并将配置写入其中。
回答by Sam Kah Chiin
Inside your spec/spec_helper
在你的里面 spec/spec_helper
RSpec.configure do |config|
config.formatter = :documentation
end
so you don't have to run the flag everytime.
所以你不必每次都运行标志。
回答by Nitesh
Use:
用:
rspec spec --format documentation

