Guardfile for running single cucumber feature in subdirectory?

强颜欢笑 提交于 2019-12-09 18:13:20

问题


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

回答1:


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!




回答2:


The --no-profile flag doesn't seem to be needed anymore, furthermore it results in not displaying any information about the run features to the console (e.g. code snippets for not yet implemented steps), which is definitely not what you want.

Today's way to go seems to be to use :all_after_pass flag like this (in your Guardfile):

guard 'cucumber', :cli => '--drb', :all_on_start => false, :all_after_pass => false do

Hope this helps.



来源:https://stackoverflow.com/questions/6076399/guardfile-for-running-single-cucumber-feature-in-subdirectory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!