Class: Cucumber::Formatter::Json

Inherits:
GherkinFormatterAdapter show all
Includes:
Io
Defined in:
lib/cucumber/formatter/json.rb

Overview

The formatter used for --format json

Direct Known Subclasses

JsonPretty

Instance Method Summary collapse

Methods included from Io

#ensure_dir, #ensure_file, #ensure_io

Methods inherited from GherkinFormatterAdapter

#before_background, #before_examples, #before_feature, #before_feature_element, #before_features, #before_step, #before_step_result, #embed

Constructor Details

#initialize(step_mother, io, options) ⇒ Json

Returns a new instance of Json.



12
13
14
15
16
# File 'lib/cucumber/formatter/json.rb', line 12

def initialize(step_mother, io, options)
  @io = ensure_io(io, "json")
  @obj = {'features' => []}
  super(Gherkin::Formatter::JSONFormatter.new(nil), false)
end

Instance Method Details

#after_feature(feature) ⇒ Object



18
19
20
21
# File 'lib/cucumber/formatter/json.rb', line 18

def after_feature(feature)
  super
  @obj['features'] << @gf.gherkin_object
end

#after_features(features) ⇒ Object



23
24
25
# File 'lib/cucumber/formatter/json.rb', line 23

def after_features(features)
  @io.write(@obj.to_json)
end