Class: Given::NaturalAssertion
- Inherits:
-
Object
- Object
- Given::NaturalAssertion
- Defined in:
- lib/given/natural_assertion.rb
Constant Summary collapse
- VOID_SEXP =
[:void_stmt]
Instance Method Summary collapse
- #has_content? ⇒ Boolean
-
#initialize(clause_type, block, example, line_extractor) ⇒ NaturalAssertion
constructor
A new instance of NaturalAssertion.
- #message ⇒ Object
Constructor Details
#initialize(clause_type, block, example, line_extractor) ⇒ NaturalAssertion
Returns a new instance of NaturalAssertion.
26 27 28 29 30 31 |
# File 'lib/given/natural_assertion.rb', line 26 def initialize(clause_type, block, example, line_extractor) @clause_type = clause_type @evaluator = Evaluator.new(example, block) @line_extractor = line_extractor set_file_and_line(block) end |
Instance Method Details
#has_content? ⇒ Boolean
35 36 37 38 |
# File 'lib/given/natural_assertion.rb', line 35 def has_content? return true unless NATURAL_ASSERTIONS_SUPPORTED assertion_sexp != VOID_SEXP end |
#message ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/given/natural_assertion.rb', line 40 def @output = "#{@clause_type} expression failed at #{source_line}\n" if NATURAL_ASSERTIONS_SUPPORTED @output << "Failing expression: #{source.strip}\n" if @clause_type != "Then" explain_failure display_pairs(expression_value_pairs) @output << "\n" else @output << "Failing expression (possibly truncated): #{source.strip}\n" end @output end |