Sha256: 6d23f36384b5386928998e5f773d44ef660598178acca0802207726dcbddcbc0

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'turnip_formatter/resource/scenario/base'

module TurnipFormatter
  module Resource
    module Scenario
      class Pending < Base
        #
        # Return steps
        #
        # example:
        #
        #   When foo
        #    And bar
        #    And baz  <= pending line
        #   Then piyo
        #
        #   #<Step 'foo'>.status = :passed
        #   #<Step 'bar'>.status = :passed
        #   #<Step 'baz'>.status = :pending
        #   #<Step 'piyo'>.status = :unexecute
        #
        def steps
          steps = super

          arys = steps.group_by { |s| (s.line <=> pending_line_number).to_s }

          arys['-1'].each { |s| s.status = :passed    } unless arys['-1'].nil?
          arys['0'].each  { |s| s.status = :pending   } unless arys['0'].nil?
          arys['1'].each  { |s| s.status = :unexecute } unless arys['1'].nil?

          steps
        end

        private

        def pending_line_number
          example.metadata[:line_number]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.6 lib/turnip_formatter/resource/scenario/pending.rb
turnip_formatter-0.6.0.pre.beta.5 lib/turnip_formatter/resource/scenario/pending.rb
turnip_formatter-0.6.0.pre.beta.4 lib/turnip_formatter/resource/scenario/pending.rb
turnip_formatter-0.6.0.pre.beta.3 lib/turnip_formatter/resource/scenario/pending.rb