Sha256: 207bde4ace974f34fb3ddc339a23407a86f72404a72e47339ac349567e3bf2c5

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'delegate'

module Cucumber
  # Represents the current status of a running test case.
  #
  # This wraps a `Cucumber::Core::Test::Case` and delegates
  # many methods to that object.
  #
  # We decorete the core object with the current result.
  # In the first Before hook of a scenario, this will be an
  # instance of `Cucumber::Core::Test::Result::Unknown`
  # but as the scenario runs, it will be updated to reflect
  # the passed / failed / undefined / skipped status of
  # the test case.
  #
  module RunningTestCase
    def self.new(test_case)
      TestCase.new(test_case)
    end

    class TestCase < SimpleDelegator
      def initialize(test_case, result = Core::Test::Result::Unknown.new)
        @test_case = test_case
        @result = result
        super test_case
      end

      def accept_hook?(hook)
        hook.tag_expressions.all? { |expression| @test_case.match_tags?(expression) }
      end

      def exception
        return unless @result.failed?

        @result.exception
      end

      def status
        @result.to_sym
      end

      def failed?
        @result.failed?
      end

      def passed?
        !failed?
      end

      def source_tag_names
        tags.map &:name
      end

      def with_result(result)
        self.class.new(@test_case, result)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
cucumber-9.1.1 lib/cucumber/running_test_case.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/running_test_case.rb
cucumber-9.1.0 lib/cucumber/running_test_case.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/running_test_case.rb
cucumber-9.0.2 lib/cucumber/running_test_case.rb
cucumber-9.0.1 lib/cucumber/running_test_case.rb
cucumber-9.0.0 lib/cucumber/running_test_case.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/running_test_case.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/running_test_case.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/running_test_case.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/running_test_case.rb
cucumber-8.0.0 lib/cucumber/running_test_case.rb
cucumber-8.0.0.rc.1 lib/cucumber/running_test_case.rb