如果没有可用的标签,则运行标记的规范或ALL

Dmy*_*iak 6 ruby tdd rspec ruby-on-rails cucumber

我正在使用rspec和黄瓜守卫.要连续运行所选的规格,我只需使用focus标签来确定我想要处理的内容.

但问题是,如果没有该标签的规格,我想运行所有规格.

我怎样才能做到这一点?

注意::我知道所有RSpec选项.所以在阅读完问题后再回复.

Joh*_*hir 7

我使用以下配置实现了您描述的行为:

# to run only specific specs, add :focus to the spec
#   describe "foo", :focus do
# OR
#   it "should foo", :focus do
config.treat_symbols_as_metadata_keys_with_true_values = true # default in rspec 3
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
Run Code Online (Sandbox Code Playgroud)