Class: Refute
- Inherits:
-
Gloo::Core::Verb
- Object
- Gloo::Core::Verb
- Refute
- Defined in:
- lib/refute.rb
Overview
Refute that [it] is true. (Assert that [it] is false.)
Constant Summary collapse
- KEYWORD =
'refute'.freeze
- KEYWORD_SHORT =
'expect_not'.freeze
- DEFAULT_MESSAGE =
'Refutation failed'.freeze
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the verb's documentation data.
-
.keyword ⇒ Object
Get the Verb's keyword.
-
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
Instance Method Summary collapse
-
#get_message ⇒ Object
Get the refutation message.
-
#run ⇒ Object
Run the verb.
Class Method Details
.doc_data ⇒ Object
Get the verb's documentation data.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/refute.rb', line 65 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'Refute an expectation about the state or ' \ 'results. The verb looks at the value of it. If it is false, ' \ 'then the assertion passes, otherwise it fails.', :syntax => [ 'refute {optional expectation message}' ], :parameters => [ "optional expectation message — A textual statement about " \ "what was NOT expected. Optional. If none provided the " \ "default \"#{DEFAULT_MESSAGE}\" will be shown." ], :result => 'Validates a negative assumption and reports failures (or success).', :examples => <<~EXAMPLES.strip refute [test] : description [string] : Refute an operation on_test [script] : eval false refute 'false should be false' EXAMPLES } end |
.keyword ⇒ Object
Get the Verb's keyword.
14 15 16 |
# File 'lib/refute.rb', line 14 def self.keyword return KEYWORD end |
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
21 22 23 |
# File 'lib/refute.rb', line 21 def self.keyword_shortcut return KEYWORD_SHORT end |
Instance Method Details
#get_message ⇒ Object
Get the refutation message.
49 50 51 52 53 54 55 56 |
# File 'lib/refute.rb', line 49 def if @tokens.token_count > 1 expr = Gloo::Expr::Expression.new( @engine, @tokens.params ) result = expr.evaluate return result end return DEFAULT_MESSAGE end |
#run ⇒ Object
Run the verb.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/refute.rb', line 28 def run begin @engine.context_object.refute_count += 1 if @engine.heap.it.is_false? # Refutation passes @engine.context_object.passed = true return true else # Refutation fails @engine.context_object.passed = false @engine.context_object.() return false end rescue => ex @engine.log_exception ex end end |