Skip to content

Instantly share code, notes, and snippets.

@ryansch
Created March 27, 2012 23:50
Show Gist options
  • Select an option

  • Save ryansch/2221582 to your computer and use it in GitHub Desktop.

Select an option

Save ryansch/2221582 to your computer and use it in GitHub Desktop.
Guardfile monkeypatch adding rspec style focus tags to cucumber
# Add focus support to cucumber
require 'guard/cucumber'
::Guard::Cucumber::Runner.class_eval do
class << self
alias original_command cucumber_command
def cucumber_command(paths, options={})
command = original_command(paths, options)
has_focus = paths.any? &method(:has_focus?)
command += " --tags @focus:4" if has_focus
command
end
def has_focus?(file)
focus_regexp = /^\s*@focus/
extension = '.feature'
begin
File.read(file) =~ focus_regexp
rescue Errno::EISDIR => e
Dir.glob("#{file}/**/*#{extension}").any? &method(:has_focus?)
rescue Errno::ENOENT => e
UI.debug "\e[31mMissing directory: #{base_path}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment