lib/pdk/report/event.rb
def sanitise_state(value)
        if value.nil? || (value.is_a?(String) && value.empty?)
          raise ArgumentError, _('State not specified.')
        end

        value = value.to_sym if value.is_a?(String)
        unless value.is_a?(Symbol)
          raise ArgumentError, _('State must be a Symbol, not %{type}') % { type: value.class }
        end

        valid_states = [:passed, :error, :failure, :skipped]
        unless valid_states.include?(value)
          raise ArgumentError, _('Invalid state %{state}. Valid states are: %{valid}.') % {
            state: value.inspect,
            valid: valid_states.map(&:inspect).join(', '),
          }
        end

        value
      end
# Munges and validates the state of the event.
#
# The valid event states are:
#   :passed  - The event represents a passing test.
#   :error   - The event represents a test that could not be completed due
#              to an unexpected error.
#   :failure - The event represents a failing test.
#   :skipped - The event represents a test that was skipped.
#
# @param value [Symbol, String] The state of the event. If passed as
#   a String, it will be turned into a Symbol before validation.
#
# @return [Symbol] The sanitised state type.
#
# @raise [ArgumentError] if the value is nil, an empty String, or not
#   a String or Symbol representation of a valid state.
Munges and validates the state of the event.
The valid event states are:
:passed  - The event represents a passing test.
:error   - The event represents a test that could not be completed due
to an unexpected error.
:failure - The event represents a failing test.
:skipped - The event represents a test that was skipped.
Munges and validates the state of the event . The valid event states are : : passed - The event represents a passing test . : error - The event represents a test that could not be completed due to an unexpected error . : failure - The event represents a failing test . : skipped - The event represents a test that was skipped .
def sanitise_state(value)
        if value.nil? || (value.is_a?(String) && value.empty?)
          raise ArgumentError, _('State not specified.')
        end
        value = value.to_sym if value.is_a?(String)
        unless value.is_a?(Symbol)
          raise ArgumentError, _('State must be a Symbol, not %{type}') % { type: value.class }
        end
        valid_states = [:passed, :error, :failure, :skipped]
        unless valid_states.include?(value)
          raise ArgumentError, _('Invalid state %{state}. Valid states are: %{valid}.') % {
            state: value.inspect,
            valid: valid_states.map(&:inspect).join(', '),
          }
        end
        value
      end
def sanitise_state ( value ) if value . nil? || ( value . is_a? ( String ) && value . empty? ) raise ArgumentError , _ ( 'State not specified.' ) end value = value . to_sym if value . is_a? ( String ) unless value . is_a? ( Symbol ) raise ArgumentError , _ ( 'State must be a Symbol, not %{type}' ) % { type : value . class } end valid_states = [ :passed , :error , :failure , :skipped ] unless valid_states . include? ( value ) raise ArgumentError , _ ( 'Invalid state %{state}. Valid states are: %{valid}.' ) % { state : value . inspect , valid : valid_states . map ( & :inspect ) . join ( ', ' ) , } end value end
Munges and validates the state of the event.
Munges and validates the state of the event .
The sanitised state type.
The sanitised state type .
Symbol
[ArgumentError] if the value is nil, an empty String, or not a String or Symbol representation of a valid state.
[ ArgumentError ] if the value is nil an empty String or not a String or Symbol representation of a valid state .
value
The state of the event. If passed as a String, it will be turned into a Symbol before validation.
The state of the event . If passed as a String it will be turned into a Symbol before validation .