Class: TurnipFormatter::StepTemplate::Exception

Inherits:
Base
  • Object
show all
Defined in:
lib/turnip_formatter/step_template/exception.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

hooks, inherited, on_failed, on_passed, on_pending

Class Method Details

.cssObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/turnip_formatter/step_template/exception.rb', line 11

def self.css
  <<-EOS
    section.scenario div.steps div.step_exception {
        margin: 1em 0em;
        padding: 1em;
        border: 1px solid #999999;
        background-color: #eee8d5;
        color: #586e75;
    }

    section.scenario div.steps div.step_exception dd {
        margin-top: 1em;
        margin-left: 1em;
    }

    pre.source {
        font-size: 12px;
        font-family: monospace;
        background-color: #073642;
        color: #dddddd;
    }

    pre.source code.ruby {
        padding: 0.1em 0 0.2em 0;
    }

    pre.source code.ruby .linenum {
        width: 75px;
        color: #fffbd3;
        padding-right: 1em;
    }

    pre.source code.ruby .offending {
        background-color: gray;
    }
  EOS
end

Instance Method Details

#build_failed(step) ⇒ Object

Parameters:

  • step (TurnipFormatter::Resource::Step::Failure)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/turnip_formatter/step_template/exception.rb', line 52

def build_failed(step)
  datas = step.exceptions.map do |e|
    backtrace = formatted_backtrace(step.example, e)
    code = extractor.snippet([backtrace.first])

    {
      code: code,
      message: e.to_s,
      backtrace: backtrace,
    }
  end

  render(exceptions: datas)
end

#build_pending(step) ⇒ Object

Parameters:

  • step (TurnipFormatter::Resource::Step::Pending)


70
71
72
73
74
75
76
77
78
# File 'lib/turnip_formatter/step_template/exception.rb', line 70

def build_pending(step)
  datas = [{
             code: nil,
             message: step.pending_message,
             backtrace: [step.pending_location]
           }]

  render(exceptions: datas)
end