Class: Spectre::RunInfo

Inherits:
Object show all
Defined in:
lib/spectre.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, data = nil) ⇒ RunInfo

Returns a new instance of RunInfo.



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/spectre.rb', line 138

def initialize spec, data=nil
  @spec = spec
  @data = data
  @started = nil
  @finished = nil
  @error = nil
  @failure = nil
  @skipped = false
  @log = []
  @expectations = []
  @properties = {}
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



135
136
137
# File 'lib/spectre.rb', line 135

def data
  @data
end

#errorObject

Returns the value of attribute error.



135
136
137
# File 'lib/spectre.rb', line 135

def error
  @error
end

#expectationsObject (readonly)

Returns the value of attribute expectations.



136
137
138
# File 'lib/spectre.rb', line 136

def expectations
  @expectations
end

#failureObject

Returns the value of attribute failure.



135
136
137
# File 'lib/spectre.rb', line 135

def failure
  @failure
end

#finishedObject

Returns the value of attribute finished.



135
136
137
# File 'lib/spectre.rb', line 135

def finished
  @finished
end

#logObject (readonly)

Returns the value of attribute log.



136
137
138
# File 'lib/spectre.rb', line 136

def log
  @log
end

#propertiesObject (readonly)

Returns the value of attribute properties.



136
137
138
# File 'lib/spectre.rb', line 136

def properties
  @properties
end

#skippedObject

Returns the value of attribute skipped.



135
136
137
# File 'lib/spectre.rb', line 135

def skipped
  @skipped
end

#specObject

Returns the value of attribute spec.



135
136
137
# File 'lib/spectre.rb', line 135

def spec
  @spec
end

#startedObject

Returns the value of attribute started.



135
136
137
# File 'lib/spectre.rb', line 135

def started
  @started
end

Instance Method Details

#durationObject



151
152
153
# File 'lib/spectre.rb', line 151

def duration
  @finished - @started
end

#error?Boolean

Returns:

  • (Boolean)


163
164
165
# File 'lib/spectre.rb', line 163

def error?
  @error != nil
end

#failed?Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/spectre.rb', line 159

def failed?
  @failure != nil
end

#skipped?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/spectre.rb', line 155

def skipped?
  @skipped
end

#statusObject



167
168
169
170
171
172
173
# File 'lib/spectre.rb', line 167

def status
  return :error if error?
  return :failed if failed?
  return :skipped if skipped?

  return :success
end

#to_hObject



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/spectre.rb', line 175

def to_h
  date_format = '%FT%T.%L%:z'

  {
    spec: @spec.name,
    data: @data,
    started: @started.strftime(date_format),
    finished: @finished.strftime(date_format),
    error: @error,
    failure: @failure,
    skipped: @skipped,
    log: @log.map { |timestamp, message, level, name| [timestamp.strftime(date_format), message, level, name] },
    expectations: @expectations,
    properties: @properties,
  }
end