Module: LapisLazuli::WorldModule::Annotate

Includes:
ArgParse
Included in:
LapisLazuli
Defined in:
lib/lapis_lazuli/world/annotate.rb

Overview

Module with annotation related functionality

Annotations are embedded into the report via cucumber’s embed function, and that means they’re embedded at the step level.

They’re also stored at scenario scope, so one step in a scenario can access annotations made in another step.

Constant Summary

Constants included from ArgParse

ArgParse::ERROR_OPTIONS

Instance Method Summary collapse

Methods included from ArgParse

#make_list_from_item, #make_list_from_nested, #parse_args

Instance Method Details

#annotate(*args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lapis_lazuli/world/annotate.rb', line 27

def annotate(*args)
  @annotations ||= {}

  scope = scenario.scope(true) || 'items'
  stuff = parse_args({}, scope, *args)

  for_scope = @annotations.fetch(scope, [])
  for_scope << stuff[scope]
  @annotations[scope] = for_scope

  if self.respond_to? "embed"
    embed(JSON.generate(stuff), 'application/json')
  end
end

#annotationsObject



42
43
44
# File 'lib/lapis_lazuli/world/annotate.rb', line 42

def annotations
  @annotations
end