Parent

Included Modules

Class/Module Index [+]

Quicksearch

Gherkin::Formatter::JSONFormatter

Attributes

gherkin_object[R]

Public Class Methods

new(io) click to toggle source

Creates a new instance that writes the resulting JSON to io. If io is nil, the JSON will not be written, but instead a Ruby object can be retrieved with gherkin_object

# File lib/gherkin/formatter/json_formatter.rb, line 17
def initialize(io)
  @io = io
end

Public Instance Methods

background(background) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 30
def background(background)
  feature_elements << background.to_hash
end
embedding(mime_type, data) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 58
def embedding(mime_type, data)
  embeddings << {'mime_type' => mime_type, 'data' => encode64s(data)}
end
eof() click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 62
def eof
  @io.write(@gherkin_object.to_json) if @io
end
examples(examples) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 42
def examples(examples)
  all_examples << examples.to_hash
end
feature(feature) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 26
def feature(feature)
  @gherkin_object = feature.to_hash
end
match(match) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 50
def match(match)
  last_step['match'] = match.to_hash
end
result(result) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 54
def result(result)
  last_step['result'] = result.to_hash
end
scenario(scenario) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 34
def scenario(scenario)
  feature_elements << scenario.to_hash
end
scenario_outline(scenario_outline) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 38
def scenario_outline(scenario_outline)
  feature_elements << scenario_outline.to_hash
end
step(step) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 46
def step(step)
  current_steps << step.to_hash
end
uri(uri) click to toggle source
# File lib/gherkin/formatter/json_formatter.rb, line 21
def uri(uri)
  # We're ignoring the uri - we don't want it as part of the JSON
  # (The pretty formatter uses it just for visual niceness - comments)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.