Evo*_*lve 155 ruby rspec colors configuration-files
如何在Ubuntu中为RSpec设置全局配置.
具体来说, - color和--format specdoc在我的所有项目中保持打开状态(即每次我在任何地方运行rspec).
aby*_*byx 236
正如您在此处的文档中所看到的,预期用途是创建~/.rspec并在其中放置您的选项,例如--color.
要~/.rspec使用该--color选项快速创建文件,只需运行:
echo '--color' >> ~/.rspec
Run Code Online (Sandbox Code Playgroud)
Sha*_*oke 149
也可以spec_helper.rb在所有项目中使用文件.该文件应包括以下内容:
RSpec.configure do |config|
# Use color in STDOUT
config.color = true
# Use color not only in STDOUT but also in pagers and files
config.tty = true
# Use the specified formatter
config.formatter = :documentation # :progress, :html,
# :json, CustomFormatterClass
end
Run Code Online (Sandbox Code Playgroud)
任何示例文件都必须要求帮助程序才能使用该选项.
Chr*_*nig 12
在您的spec_helper.rb文件中,包含以下选项:
RSpec.configure do |config|
config.color_enabled = true
end
Run Code Online (Sandbox Code Playgroud)
然后,您必须在每个*_spec.rb文件中要求使用该选项.
如果您使用rake运行rspec测试,那么您可以编辑spec/spec.opts
http://rspec.info/rails/runners.html