Class: Expresenter::Pass

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

Overview

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

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) ⇒ Pass

Returns A passed spec result.

Returns:

  • (Pass)

    A passed spec result.



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

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

Instance Method Details

#charString

Express the result with one char.

Returns:

  • (String)

    The char that identify the result.



58
59
60
61
62
63
64
65
66
# File 'lib/expresenter/pass.rb', line 58

def char
  if success?
    "."
  elsif warning?
    "W"
  else
    "I"
  end
end

#emojiString

Express the result with one emoji.

Returns:

  • (String)

    The emoji that identify the result.



71
72
73
74
75
76
77
78
79
# File 'lib/expresenter/pass.rb', line 71

def emoji
  if success?
    ""
  elsif warning?
    "⚠️"
  else
    "💡"
  end
end

#failed?Boolean

Did the test fail?

Returns:

  • (Boolean)

    The spec passed or failed?



20
21
22
# File 'lib/expresenter/pass.rb', line 20

def failed?
  false
end

#failure?Boolean

The state of failure.

Returns:

  • (Boolean)

    The test was a failure?



27
28
29
# File 'lib/expresenter/pass.rb', line 27

def failure?
  false
end

#info?Boolean

The state of info.

Returns:

  • (Boolean)

    The test was an info?



34
35
36
# File 'lib/expresenter/pass.rb', line 34

def info?
  !error.nil?
end

#to_symSymbol

Identify the state of the result.

Returns:

  • (Symbol)

    The identifier of the state.



48
49
50
51
52
53
# File 'lib/expresenter/pass.rb', line 48

def to_sym
  return :success if success?
  return :warning if warning?

  :info
end

#warning?Boolean

The state of warning.

Returns:

  • (Boolean)

    The test was a warning?



41
42
43
# File 'lib/expresenter/pass.rb', line 41

def warning?
  got.equal?(false)
end