用于在子目录中运行单个黄瓜功能的 Guardfile? [英] Guardfile for running single cucumber feature in subdirectory?

查看:16
本文介绍了用于在子目录中运行单个黄瓜功能的 Guardfile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的功能组织在子文件夹中,如下所示:

I have my features organized in subfolders, like this:

app/
  features/
     users/
       feature1.feature
       feature2.feature

但每次我保存一项功能时,Guard 都会运行我的所有功能(不仅仅是已编辑的功能).如何将其更改为仅运行已保存的那个?

But everytime I save a feature, Guard runs all my features (not just the one that was edited). How can I change it to only run the one that was saved?

这是我的 Cucumber Guardfile:

Here's my Guardfile for Cucumber:

guard 'cucumber', :cli => "--drb --require features/support --require features/step_definitions" do
  watch(%r{features/.+.feature})
  watch(%r{features/support/.+})          { 'features' }
  watch(%r{features/step_definitions/(.+)_steps.rb}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end

推荐答案

Aph,答案就在 文档:

你很重要了解 Cucumber 是如何获得的配置,因为它通常是奇怪行为的起源守护黄瓜.

It's very important that you understand how Cucumber gets configured, because it's often the origin of strange behavior of guard-cucumber.

Cucumber 使用 cucumber.yml定义特定运行的配置文件配置.当你通过通过 :cli 选项进行配置但不包括特定的个人资料使用--profile,然后从默认配置配置文件也被使用.

Cucumber uses cucumber.yml for defining profiles of specific run configurations. When you pass configurations through the :cli option but don't include a specific profile with --profile, then the configurations from the default profile are also used.

例如,当您使用默认 cucumber.yml 由cucumber-rails,然后是默认的profile 强制guard-cucumber始终运行所有功能,因为它追加 features 文件夹.

For example, when you're using the default cucumber.yml generated by cucumber-rails, then the default profile forces guard-cucumber to always run all features, because it appends the features folder.

仅从 Guard 配置 Cucumber

Configure Cucumber solely from Guard

如果你想从单独守卫,然后你应该通过--no-profile 到 :cli 选项.

If you want to configure Cucumber from Guard solely, then you should pass --no-profile to the :cli option.

因此,为 :cli 选项传入 --no-profile 现在可以正常工作,并且我的行为正常.

So, passing in --no-profile for the :cli option works now, and I'm getting normal behavior.

为我不阅读文档而感到羞耻!

Shame on me for not reading the docs!

这篇关于用于在子目录中运行单个黄瓜功能的 Guardfile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆