Sha256: 502e57cd82705205a5ae3bc9d6b93c97d896b480a5a5a69ef1b3246b4dc14282

Contents?: true

Size: 819 Bytes

Versions: 19

Compression:

Stored size: 819 Bytes

Contents

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

require 'turnip_formatter/scenario'
require 'turnip_formatter/step/failure'

module TurnipFormatter
  module Scenario
    class NotFailedScenarioError < ::StandardError; end
    class NoExistFailedStepInformationError < ::StandardError; end

    class Failure
      include TurnipFormatter::Scenario

      def steps
        steps = super
        steps[offending_line].extend TurnipFormatter::Step::Failure
        steps
      end

      def validation
        raise NotFailedScenarioError if status != 'failed'
        offending_line
        super
      end

      private

      def offending_line
        unless example.exception.backtrace.last =~ /:in step:(?<stepno>\d+) `/
          raise NoExistFailedStepInformationError
        end
        $~[:stepno].to_i
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
turnip_formatter-0.2.11 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.10 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.9 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.8 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.7 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.6 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.5 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.4 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.3 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.2 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.1 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.2.0 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.1.2 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.1.1 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.1.0 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.0.6 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.0.5 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.0.4 lib/turnip_formatter/scenario/failure.rb
turnip_formatter-0.0.3 lib/turnip_formatter/scenario/failure.rb