Method: Tapout::Reporters::Abstract#backtrace_snippets_chain
- Defined in:
- lib/tapout/reporters/abstract.rb
#backtrace_snippets_chain(test) ⇒ Array<String,String>
Returns an associative array of backtraces along with corresponding source code, if available.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/tapout/reporters/abstract.rb', line 319 def backtrace_snippets_chain(test) code = test['exception']['snippet'] file = test['exception']['file'] line = test['exception']['line'] chain = [] bts = backtrace(test) if bts.empty? if file && line bts << "#{file}:#{line}" end end bts.each do |bt| if md = /(.+?):(\d+)/.match(bt) chain << [bt, code_snippet('file'=>md[1], 'line'=>md[2].to_i)] else chain << [bt, nil] end end if chain.first && chain.first.last.nil? chain[0][1] = code_snippet('snippet'=>code, 'line'=>line) end chain end |