Guardfile在子目录中运行单个黄瓜功能? [英] Guardfile for running single cucumber feature in subdirectory?
问题描述
我在子文件夹中组织了我的功能,如下所示:
app /
功能/
users /
feature1.feature
feature2.feature
但每次我保存功能,Guard运行我的所有功能(不仅仅是编辑的功能)。如何更改它只运行保存的那个?
这是我的Cucumber的Guardfile:
guard'cucumber' :cli => --drb --require features / support --require features / step_definitionsdo
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
该问题的答案在文档中:
这很重要,你
了解Cucumber如何配置
,因为它通常是
的奇怪行为的起源
guard-cucumber。
Cucumber对
使用cucumber.yml定义特定运行
配置的配置文件。当您通过:cli选项
传递
配置,但不包括具有--profile的特定配置文件
时,则默认
配置文件中的
配置
例如,当你使用
默认的cucumber.yml生成的
cucumber-rails,那么默认的
profile强制保护黄瓜到
总是运行所有功能,因为
追加了features文件夹。
只从Guard配置Cucumber
如果你想从
Guard单独配置Cucumber,那么你应该将
--no-profile传递给:cli选项。
所以,传递 - no-profile
cli 选项现在可以正常工作,而且我的行为正常。
我没有阅读文档可耻!
I have my features organized in subfolders, like this:
app/
features/
users/
feature1.feature
feature2.feature
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?
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, the answer was right there in the documentation:
It's very important that you understand how Cucumber gets configured, because it's often the origin of strange behavior of guard-cucumber.
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.
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.
Configure Cucumber solely from Guard
If you want to configure Cucumber from Guard solely, then you should pass --no-profile to the :cli option.
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屋!