Class: Bumps::JSONFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/bumps/json_formatter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ JSONFormatter

Returns a new instance of JSONFormatter.



12
13
14
15
# File 'lib/bumps/json_formatter.rb', line 12

def initialize step_mother, io, options
  @io = io
  @features = {}
end

Class Method Details

.nowObject



8
9
10
# File 'lib/bumps/json_formatter.rb', line 8

def self.now
  Time.now
end

Instance Method Details

#after_feature(feature) ⇒ Object



50
51
52
53
# File 'lib/bumps/json_formatter.rb', line 50

def after_feature(feature)
  @feature.merge!({'finished' => JSONFormatter.now.iso8601, 'version' => @version})
  @features[@id] = @feature
end

#after_features(*args) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/bumps/json_formatter.rb', line 55

def after_features(*args)
  document = {
    'features' => @features  
  }

  @io.print(document.to_json)
  @io.flush
end

#after_step(step) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/bumps/json_formatter.rb', line 40

def after_step(step)
  @step = {
    'status' => step.status,
    'line' => line(step.file_colon_line)
  }
  @scenario['steps'] << @step
  @scenario['status'] = step.status unless step.status == :skipped
end

#before_feature(feature) ⇒ Object



25
26
27
28
29
30
# File 'lib/bumps/json_formatter.rb', line 25

def before_feature(feature)
  @feature = {
    'started' => JSONFormatter.now.iso8601,
    'scenarios' => []
  }
end

#before_features(*args) ⇒ Object

required to keep cukes happy



18
# File 'lib/bumps/json_formatter.rb', line 18

def before_features(*args);end

#scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/bumps/json_formatter.rb', line 32

def scenario_name(keyword, name, file_colon_line, source_indent)
 @scenario = {
   'line' => line(file_colon_line),
   'steps' => []
 }
 @feature['scenarios'] << @scenario
end

#tag_name(tag) ⇒ Object



20
21
22
23
# File 'lib/bumps/json_formatter.rb', line 20

def tag_name tag
  name, value = tag.split(":", 2)
  instance_variable_set(name, value)
end