Sha256: 9c965c9cf62ee8f71ba5e30d9805cdc906a3c225cc77687fae575068de6decfc

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

require 'turnip_formatter/step_template/base'
require 'slim'

module TurnipFormatter
  module StepTemplate
    class Exception < Base
      on_failed :build_failed
      on_pending :build_pending

      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;
          }
        EOS
      end

      #
      # @param  [RSpec::Core::Example]  example
      #
      def build_failed(example)
        build(example.exception.to_s, formatted_backtrace(example))
      end

      #
      # @param  [RSpec::Core::Example]  example
      #
      def build_pending(example)
        build(example.execution_result.pending_message, [example.location])
      end

      private

        def build(message, backtrace)
          template_step_exception.render(Object.new, { message: message, backtrace: backtrace })
        end

        def template_step_exception
          @template_step_exception ||= Slim::Template.new(File.dirname(__FILE__) + "/exception.slim")
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.4 lib/turnip_formatter/step_template/exception.rb
turnip_formatter-0.6.0.pre.beta.3 lib/turnip_formatter/step_template/exception.rb
turnip_formatter-0.6.0.pre.beta.2 lib/turnip_formatter/step_template/exception.rb
turnip_formatter-0.6.0.pre.beta.1 lib/turnip_formatter/step_template/exception.rb
turnip_formatter-0.5.0 lib/turnip_formatter/step_template/exception.rb
turnip_formatter-0.4.0 lib/turnip_formatter/step_template/exception.rb