Sha256: ac7dadf2a589dcc547ef90f8fd5c6b66db0dafe67522c51204ec264b59890102

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Cucumber
  module Core
    module Test
      module Filters
        # This filter is used for testing Cucumber itself. It adds step definitions
        # that will activate steps to have passed / failed / pending results
        # if they use conventional names.
        #
        # It was extracted from our test code, and does not have any tests of its own.
        class ActivateStepsForSelfTest < Core::Filter.new
          Failure = Class.new(StandardError)

          def test_case(test_case)
            test_case.with_steps(test_steps(test_case)).describe_to(receiver)
          end

          private

          def test_steps(test_case)
            test_case.test_steps.map do |step|
              case step.text
              when /fail/ then step.with_action { raise Failure }
              when /pending/ then step.with_action { raise Test::Result::Pending }
              when /pass/ then step.with_action { :no_op }
              else; step
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-core-13.0.3 lib/cucumber/core/test/filters/activate_steps_for_self_test.rb
cucumber-core-13.0.2 lib/cucumber/core/test/filters/activate_steps_for_self_test.rb
cucumber-core-13.0.1 lib/cucumber/core/test/filters/activate_steps_for_self_test.rb