如何关闭(禁用,取消)rspec命令行选项?

huangapple go评论53阅读模式
英文:

How can I turn off (disable, negate) an rspec command line option?

问题

在我的团队的Rails应用中,我们的.rspec文件包含--profile

我不希望在我本地运行rspec时99%的时间都显示性能分析信息。更改整个团队的.rspec不是一个选项。

在我的.rspec-local文件(它被git忽略了),我想要抑制或覆盖.rspec中的设置。

这是否可行?

如何以抑制已声明的rspec参数的语法?

英文:

In my team's Rails app, our file .rspec includes --profile.

I don't want profile information showing up 99% of the times I run rspec locally. Changing .rspec for the whole team is not an option.

In my file .rspec-local (which is gitignored), I would like to suppress or override the setting in .rspec

Is this possible?

What is the syntax to do suppress an rspec parameter already declared?

答案1

得分: 1

前缀标志选项使用 no- 来覆盖先前的声明。例如,.rspec 首先被加载,然后 .rspec-local 被第二次加载:

.rspec:

--profile
--no-color

.rspec-local:

--no-profile
--color

结果是 rspec 将不带 profile,并且带有颜色。

EDIT: TIL(今天我学到了)您可以在您的主目录中创建 ~/.rspec,它将为所有您的项目加载! 😄 不幸的是,当您的测试在 Docker 容器内运行时,这不起作用。 😞

英文:

Prefix flag options with no- to override previous declarations. For example, .rspec gets loaded first, then .rspec-local gets loaded second:

.rspec:

--profile
--no-color

.rspec-local:

--no-profile
--color

The result is that rspec will run without the profile, and with color.

EDIT: TIL that you can create ~/.rspec in your home directory and it will be loaded for all your projects! 😃 Unfortunately, that doesn't work when your tests run inside a docker container. 😞

huangapple
  • 本文由 发表于 2023年2月23日 22:31:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75546224.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定