Sha256: 0cd27d3d44b9ef1216edfea08d9aaf5aba2bcd8c41eca16bc5c4fcb2d14b40bc

Contents?: true

Size: 1009 Bytes

Versions: 12

Compression:

Stored size: 1009 Bytes

Contents

# -*- coding: utf-8 -*-

require 'turnip_formatter/step/failure'
require 'rspec/core/formatters/snippet_extractor'

module TurnipFormatter
  module StepTemplate
    module Source
      def self.build(location)
        code = extractor.snippet([location])
        '<pre class="source"><code class="ruby">' + code + '</code></pre>'
      end

      private

      def self.extractor
        @extractor ||= ::RSpec::Core::Formatters::SnippetExtractor.new
      end
    end
  end

  Template.add_scss(<<-EOS)
    pre.source {
        font-size: 12px;
        font-family: monospace;
        background-color: #073642;
        color: #dddddd;

        code.ruby {
            padding: 0.1em 0 0.2em 0;

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

            .offending { background-color: gray; }
        }
    }
  EOS

  Step::Failure.add_template(StepTemplate::Source) do
    example.exception.backtrace.first
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
turnip_formatter-0.2.11 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.10 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.9 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.8 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.7 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.6 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.5 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.4 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.3 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.2 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.1 lib/turnip_formatter/step_template/source.rb
turnip_formatter-0.2.0 lib/turnip_formatter/step_template/source.rb