Exception: Expresenter::Fail

Inherits:
StandardError
  • Object
show all
Includes:
Base
Defined in:
lib/expresenter/fail.rb

Overview

The class that is responsible for reporting that the expectation is false.

Instance Attribute Summary

Attributes included from Base

#actual, #error, #expected, #got, #level, #matcher

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#colored_char, #colored_string, #definition, #error?, #initialize, #inspect, #maybe_negate, #negate?, #passed?, #success?, #summary, #titre, #to_s, #valid?

Class Method Details

.with(**details) ⇒ Object

Raises:

  • (Fail)

    A failed spec result.



11
12
13
# File 'lib/expresenter/fail.rb', line 11

def self.with(**details)
  raise new(**details)
end

Instance Method Details

#charString

Express the result with one char.

Returns:

  • (String)

    The char that identify the result.



53
54
55
56
57
58
59
# File 'lib/expresenter/fail.rb', line 53

def char
  if failure?
    "F"
  else
    "E"
  end
end

#emojiString

Express the result with one emoji.

Returns:

  • (String)

    The emoji that identify the result.



64
65
66
67
68
69
70
# File 'lib/expresenter/fail.rb', line 64

def emoji
  if failure?
    ""
  else
    "💥"
  end
end

#failed?Boolean

Did the test fail?

Returns:

  • (Boolean)

    The spec passed or failed?



18
19
20
# File 'lib/expresenter/fail.rb', line 18

def failed?
  true
end

#failure?Boolean

The state of failure.

Returns:

  • (Boolean)

    The test was a failure?



25
26
27
# File 'lib/expresenter/fail.rb', line 25

def failure?
  !error?
end

#info?Boolean

The state of info.

Returns:

  • (Boolean)

    The test was an info?



32
33
34
# File 'lib/expresenter/fail.rb', line 32

def info?
  false
end

#to_symSymbol

Identify the state of the result.

Returns:

  • (Symbol)

    The identifier of the state.



46
47
48
# File 'lib/expresenter/fail.rb', line 46

def to_sym
  failure? ? :failure : :error
end

#warning?Boolean

The state of warning.

Returns:

  • (Boolean)

    The test was a warning?



39
40
41
# File 'lib/expresenter/fail.rb', line 39

def warning?
  false
end