Class: TurnipFormatter::Template

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, RSpec::Core::BacktraceFormatter
Defined in:
lib/turnip_formatter/template.rb

Instance Method Summary collapse

Instance Method Details



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/turnip_formatter/template.rb', line 40

def print_footer(total_count, failed_count, pending_count, total_time)
  update_report_js_tmp = '<script type="text/javascript">document.getElementById("%s").innerHTML = "%s";</script>'
  update_report_js = ''

  
  %w{ total_count failed_count pending_count total_time }.each do |key|
    update_report_js += update_report_js_tmp % [key, eval(key)]
  end

  <<-EOS
        </div>
        #{update_report_js}
      </body>
    </html>
  EOS
end


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
# File 'lib/turnip_formatter/template.rb', line 11

def print_header
  <<-EOS
    <!DOCTYPE html>
      <head>
        <meta charset="UTF-8">
        <style>
        #{File.read(File.dirname(__FILE__) + '/formatter.css')}
        </style>
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
        <script>
          $(function() {
              ["passed", "failed", "pending"].forEach(function(status) {
                  $('#' + status + '_check').click(function() {
                      if (this.checked) {
                          $('.scenario.' + status).show();
                      } else {
                          $('.scenario.' + status).hide();
                      }
                  });
              });
          });
        </script>
      </head>
      <body>
        #{report_area}
        <div id="main" role="main">
  EOS
end


61
62
63
64
65
66
67
68
69
70
# File 'lib/turnip_formatter/template.rb', line 61

def print_runtime_error(example, exception)
  
  if example.exception
    example_backtrace = format_backtrace(example.exception.backtrace[0..14], example.).map do |l|
      RSpec::Core::Metadata::relative_path(l)
    end
  end

  template_exception.result(binding)
end


57
58
59
# File 'lib/turnip_formatter/template.rb', line 57

def print_scenario(scenario)
  template_scenario.result(binding)
end