Sha256: 312948cec4f2263f862eb2af19c7ca3d13f51d08dfacf913691c99934bf56e66

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

require_relative 'verifier'
require_relative '../verification_result'

module Dragnet
  module Verifiers
    # Verifies the +result+ field on the given MTR record.
    class ResultVerifier < Dragnet::Verifiers::Verifier
      # Performs the verification. If the +result+ field contains the "failed"
      # text then a +result+ key will be added to the Test Record explaining
      # the reason for the failure.
      # @return [Dragnet::VerificationResult, nil] A +VerificationResult+ object
      #   when the verification fails and +nil+ when the verification passes.
      def verify
        return if test_record.passed?

        Dragnet::VerificationResult.new(
          status: :failed,
          reason: "'result' field has the status '#{result}'"
        )
      end

      private

      # @return [String] The value for the +result+ key on the MTR file.
      def result
        @result ||= test_record.result
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragnet-5.3.1 lib/dragnet/verifiers/result_verifier.rb
dragnet-5.3.0 lib/dragnet/verifiers/result_verifier.rb
dragnet-5.2.1 lib/dragnet/verifiers/result_verifier.rb