Module: Expresenter::Common
Overview
Common collection of methods.
Constant Summary collapse
- SPACE =
White space.
" "
Instance Attribute Summary collapse
-
#actual ⇒ #object_id
readonly
Returned value by the challenged subject.
-
#definition ⇒ String
readonly
A readable string of the matcher and any expected values.
-
#error ⇒ Exception?
readonly
Any possible raised exception.
-
#got ⇒ #object_id
readonly
The result of the boolean comparison between the actual value and the expected value through the matcher.
-
#level ⇒ :MUST, ...
readonly
The requirement level of the expectation.
Instance Method Summary collapse
-
#colored_char ⇒ String
Express the result with one colored char.
-
#colored_string ⇒ String
The colored string representation of the result.
-
#error? ⇒ Boolean
The state of error.
-
#negate? ⇒ Boolean
The value of the negate instance variable.
-
#passed? ⇒ Boolean
Did the test pass?.
-
#success? ⇒ Boolean
The state of success.
-
#summary ⇒ String
The summary of the result.
-
#titre ⇒ String
Titre for the result.
-
#to_s ⇒ String
The representation of the result.
Instance Attribute Details
#actual ⇒ #object_id (readonly)
Returned value by the challenged subject.
10 11 12 |
# File 'lib/expresenter/common.rb', line 10 def actual @actual end |
#definition ⇒ String (readonly)
Returns A readable string of the matcher and any expected values.
13 14 15 |
# File 'lib/expresenter/common.rb', line 13 def definition @definition end |
#error ⇒ Exception? (readonly)
Returns Any possible raised exception.
16 17 18 |
# File 'lib/expresenter/common.rb', line 16 def error @error end |
#got ⇒ #object_id (readonly)
Returns The result of the boolean comparison between the actual value and the expected value through the matcher.
20 21 22 |
# File 'lib/expresenter/common.rb', line 20 def got @got end |
#level ⇒ :MUST, ... (readonly)
Returns The requirement level of the expectation.
23 24 25 |
# File 'lib/expresenter/common.rb', line 23 def level @level end |
Instance Method Details
#colored_char ⇒ String
Express the result with one colored char.
69 70 71 |
# File 'lib/expresenter/common.rb', line 69 def colored_char color(char) end |
#colored_string ⇒ String
The colored string representation of the result.
76 77 78 |
# File 'lib/expresenter/common.rb', line 76 def colored_string color(to_bold_s) end |
#error? ⇒ Boolean
The state of error.
42 43 44 |
# File 'lib/expresenter/common.rb', line 42 def error? !error.nil? end |
#negate? ⇒ Boolean
The value of the negate instance variable.
35 36 37 |
# File 'lib/expresenter/common.rb', line 35 def negate? @negate end |
#passed? ⇒ Boolean
Did the test pass?
28 29 30 |
# File 'lib/expresenter/common.rb', line 28 def passed? !failed? end |
#success? ⇒ Boolean
The state of success.
49 50 51 |
# File 'lib/expresenter/common.rb', line 49 def success? got.equal?(true) end |
#summary ⇒ String
The summary of the result.
56 57 58 59 60 61 62 63 64 |
# File 'lib/expresenter/common.rb', line 56 def summary if error? error. elsif actual.is_a?(::Exception) actual. else ["expected", actual.inspect, negation, "to", definition].compact.join(SPACE) end end |
#titre ⇒ String
Titre for the result.
90 91 92 93 94 95 96 |
# File 'lib/expresenter/common.rb', line 90 def titre if error? error.class.name else to_sym.to_s.capitalize end end |
#to_s ⇒ String
The representation of the result.
83 84 85 |
# File 'lib/expresenter/common.rb', line 83 def to_s "#{titre}: #{summary}." end |