Class: Guard::Cucumber::NotificationFormatter
- Inherits:
-
Object
- Object
- Guard::Cucumber::NotificationFormatter
- Includes:
- Cucumber::Formatter::Console
- Defined in:
- lib/guard/cucumber/notification_formatter.rb
Overview
The notification formatter is a Cucumber formatter that Guard::Cucumber passes to the Cucumber binary. It writes the ‘rerun.txt` file with the failed features an creates system notifications.
Instance Attribute Summary collapse
-
#step_mother ⇒ Object
readonly
Returns the value of attribute step_mother.
Instance Method Summary collapse
-
#after_feature_element(feature_element) ⇒ Object
After a feature gets run.
-
#after_features(_features) ⇒ Object
Notification after all features have completed.
- #before_background(_background) ⇒ Object
- #before_feature(feature) ⇒ Object
-
#before_feature_element(_feature_element) ⇒ Object
Before a feature gets run.
-
#initialize(step_mother, _path_or_io, options) ⇒ NotificationFormatter
constructor
Initialize the formatter.
-
#step_name(_keyword, step_match, status, _src_indent, _bckgnd, _loc) ⇒ Object
Gets called when a step is done.
Constructor Details
#initialize(step_mother, _path_or_io, options) ⇒ NotificationFormatter
Initialize the formatter.
40 41 42 43 44 45 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 40 def initialize(step_mother, _path_or_io, ) @options = @file_names = [] @step_mother = step_mother @feature = nil end |
Instance Attribute Details
#step_mother ⇒ Object (readonly)
Returns the value of attribute step_mother.
32 33 34 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 32 def step_mother @step_mother end |
Instance Method Details
#after_feature_element(feature_element) ⇒ Object
After a feature gets run.
78 79 80 81 82 83 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 78 def after_feature_element(feature_element) if @rerun @file_names << feature_element.location.to_s @rerun = false end end |
#after_features(_features) ⇒ Object
Notification after all features have completed.
59 60 61 62 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 59 def after_features(_features) notify_summary write_rerun_features if !@file_names.empty? end |
#before_background(_background) ⇒ Object
47 48 49 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 47 def before_background(_background) # NOTE: background.feature is nil on newer gherkin versions end |
#before_feature(feature) ⇒ Object
51 52 53 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 51 def before_feature(feature) @feature = feature end |
#before_feature_element(_feature_element) ⇒ Object
Before a feature gets run.
68 69 70 71 72 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 68 def before_feature_element(_feature_element) @rerun = false # TODO: show feature element name instead? # @feature = feature_element.name end |
#step_name(_keyword, step_match, status, _src_indent, _bckgnd, _loc) ⇒ Object
Gets called when a step is done.
used
95 96 97 98 99 100 101 102 103 |
# File 'lib/guard/cucumber/notification_formatter.rb', line 95 def step_name(_keyword, step_match, status, _src_indent, _bckgnd, _loc) return unless [:failed, :pending, :undefined].index(status) @rerun = true step_name = step_match.format_args(lambda { |param| "*#{param}*" }) = { title: @feature.name, image: icon_for(status) } Guard::Compat::UI.notify(step_name, ) end |