Class: MediawikiSelenium::Raita::Logger

Inherits:
Cucumber::Formatter::GherkinFormatterAdapter
  • Object
show all
Defined in:
lib/mediawiki_selenium/raita/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(_runtime, raita_options, options) ⇒ Logger

Returns a new instance of Logger.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mediawiki_selenium/raita/logger.rb', line 7

def initialize(_runtime, raita_options, options)
  # Force expanded output of outlines. Note this will effect other
  # formatters as well, but it's the only way to get a consistent JSON
  # representation of feature elements with result status and duration.
  #
  # @see https://github.com/cucumber/gherkin/issues/165
  options[:expand] = true

  super(Formatter.new, false, options)

  @db_url = URI.parse(raita_options[:url])
  @build = raita_options[:build].merge(result: { status: 'passed', duration: 0 })
end

Instance Method Details

#after_featuresObject

Log everything at once to Raita's Elasticsearch DB.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mediawiki_selenium/raita/logger.rb', line 23

def after_features(*)
  @build_id = create('build', @build)['_id']

  @gf.feature_hashes.each do |feature|
    amend_feature(feature)
    elements = feature.delete('elements')

    feature_id = create('feature', feature, @build_id)['_id']
    bulk('feature-element', elements, feature_id)

    @build[:result][:status] = change_status(
      @build[:result][:status],
      feature['result']['status']
    )
    @build[:result][:duration] += feature['result']['duration']
  end

  update('build', @build_id, @build)
end