Class: MediawikiSelenium::WarningsFormatter

Inherits:
Object
  • Object
show all
Includes:
Cucumber::Formatter::Console
Defined in:
lib/mediawiki_selenium/warnings_formatter.rb

Defined Under Namespace

Modules: FeatureWarnings

Instance Method Summary collapse

Constructor Details

#initialize(_runtime, io, _options) ⇒ WarningsFormatter

Returns a new instance of WarningsFormatter.



7
8
9
10
# File 'lib/mediawiki_selenium/warnings_formatter.rb', line 7

def initialize(_runtime, io, _options)
  @io = io
  @warning_counts = Hash.new(0)
end

Instance Method Details

#after_feature(feature) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/mediawiki_selenium/warnings_formatter.rb', line 12

def after_feature(feature)
  return unless feature.mw_warnings.any?

  feature.mw_warnings.each do |type, messages|
    messages.each { |msg| @io.puts format_string(msg, :pending) }
    @warning_counts[type] += messages.length
  end

  @io.puts
end

#after_featuresObject



23
24
25
26
27
28
29
30
31
# File 'lib/mediawiki_selenium/warnings_formatter.rb', line 23

def after_features(*)
  return unless @warning_counts.any?

  @warning_counts.each do |type, count|
    message = "#{count} warning#{count > 1 ? "s" : ""}"
    message += " due to #{type}" unless type == :default
    @io.puts format_string(message, :pending)
  end
end

#before_feature(feature) ⇒ Object



33
34
35
# File 'lib/mediawiki_selenium/warnings_formatter.rb', line 33

def before_feature(feature)
  feature.extend(FeatureWarnings)
end