netzpirat / guard-cucumber

Guard::Cucumber automatically runs your features (much like autotest)
https://rubygems.org/gems/guard-cucumber
MIT License
39 stars 56 forks source link

Save failed features from #run_all #13

Closed lmarburger closed 13 years ago

lmarburger commented 13 years ago

Read and save failed features if #run_all fails. Here's the workflow I'm going for:

  1. Save Feature1
  2. Feature1 -> fail
  3. Save a file somewhere in the codebase
  4. Feature1 -> pass
  5. All features -> Feature2 fail
  6. Save a file somewhere in the codebase
  7. Feature2 -> pass
  8. All features -> pass

From what I can tell, there's no way to tell guard-cucumber to rerun the saved failed features without calling #run_on_change. Here's my Guardfile:

guard 'cucumber', :cli => '--no-profile --drb --color --strict --format progress --format rerun --out rerun.txt',
                  :all_on_start => false do
  watch(%r{^features/.+\.feature$})
  watch(%r{^features/support/.+$}) { 'features' }
  watch(%r{^app/assets/.+$})       { 'features' }

  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
    Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
  end

  # Rerun failed features
  watch('config/routes.rb')
  watch(%r{^app/(.*)\.rb})
end

It's cheating, but I'm passing non-feature filenames to guard-cucumber which it's smart enough to ignore. The end result is when an app file is saved, the failed features are rerun.

I've only started using guard yesterday so please let me know if I'm missing something obvious. I wouldn't be surprised. In the mean time, I'm going to give this patch a try today and see how it feels.

netzpirat commented 13 years ago

Thank you very much for your contribution. I looks fine and I'll released version 0.5.2 that includes your changes.

lmarburger commented 13 years ago

Excellent! Thanks for pulling in the commit. I've been using guard-cucumber in my workflow for a few days now and it's fantastic. I can't believe I waited so long to add it to my projects.