Class: Rocha::Reporter::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/rocha/reporter/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Metadata

Returns a new instance of Metadata.



14
15
16
# File 'lib/rocha/reporter/metadata.rb', line 14

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/rocha/reporter/metadata.rb', line 12

def data
  @data
end

Instance Method Details

#[](key) ⇒ Object



18
19
20
# File 'lib/rocha/reporter/metadata.rb', line 18

def [](key)
  respond_to?(key) ? send(key) : data[key]
end

#described_classObject



63
64
65
66
# File 'lib/rocha/reporter/metadata.rb', line 63

def described_class
  STDERR.puts "described_class not implemented" if Rocha.verbose
  nil
end

#descriptionObject



72
73
74
# File 'lib/rocha/reporter/metadata.rb', line 72

def description
  data['title']
end

#exceptionObject



48
49
50
51
52
53
54
55
56
# File 'lib/rocha/reporter/metadata.rb', line 48

def exception
  return unless data['status'] == "failed"

  @exception ||= begin
    e = Reporter::SpecException.new("#{data['error']['name']}: #{data['error']['message']}")
    e.set_backtrace([])
    e
  end
end

#execution_resultObject



38
39
40
41
42
43
44
45
46
# File 'lib/rocha/reporter/metadata.rb', line 38

def execution_result
  @execution_result ||= {
    :status      => data['status'],
    :started_at  => nil,
    :finished_at => nil,
    :run_time    => data['duration'],
    :exception   => exception
  }
end

#file_pathObject Also known as: location



26
27
28
29
# File 'lib/rocha/reporter/metadata.rb', line 26

def file_path
  # FIXME: This is needed to not crash in RSpec formatters
  data['path'] || '<script.js>'
end

#full_descriptionObject



76
77
78
# File 'lib/rocha/reporter/metadata.rb', line 76

def full_description
  data['fullTitle']
end

#line_numberObject



33
34
35
36
# File 'lib/rocha/reporter/metadata.rb', line 33

def line_number
  STDERR.puts "line_number not implemented" if Rocha.verbose
  nil
end

#pendingObject



68
69
70
# File 'lib/rocha/reporter/metadata.rb', line 68

def pending
  data['status'] == "pending"
end

#pending_messageObject



58
59
60
61
# File 'lib/rocha/reporter/metadata.rb', line 58

def pending_message
  STDERR.puts "pending_message not implemented" if Rocha.verbose
  nil
end

#update(data) ⇒ Object



22
23
24
# File 'lib/rocha/reporter/metadata.rb', line 22

def update(data)
  @data.merge!(data)
end