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
# File lib/gherkin/formatter/json_formatter.rb, line 30 def background(background) feature_elements << background.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 58 def embedding(mime_type, data) embeddings << {'mime_type' => mime_type, 'data' => encode64s(data)} end
# File lib/gherkin/formatter/json_formatter.rb, line 62 def eof @io.write(@gherkin_object.to_json) if @io end
# File lib/gherkin/formatter/json_formatter.rb, line 42 def examples(examples) all_examples << examples.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 26 def feature(feature) @gherkin_object = feature.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 50 def match(match) last_step['match'] = match.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 54 def result(result) last_step['result'] = result.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 34 def scenario(scenario) feature_elements << scenario.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 38 def scenario_outline(scenario_outline) feature_elements << scenario_outline.to_hash end
# File lib/gherkin/formatter/json_formatter.rb, line 46 def step(step) current_steps << step.to_hash end
# 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