Created
March 27, 2012 23:50
-
-
Save ryansch/2221582 to your computer and use it in GitHub Desktop.
Guardfile monkeypatch adding rspec style focus tags to cucumber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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