Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guardfile for running single cucumber feature in subdirectory?

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
like image 530
neezer Avatar asked May 20 '11 18:05

neezer


2 Answers

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!

like image 191
neezer Avatar answered Oct 05 '22 07:10

neezer


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.

like image 34
Joshua Muheim Avatar answered Oct 05 '22 07:10

Joshua Muheim