Class: RSpec::Given::NaturalAssertion
- Inherits:
-
Object
- Object
- RSpec::Given::NaturalAssertion
- Defined in:
- lib/rspec/given/natural_assertion.rb
Constant Summary collapse
- VOID_SEXP =
[:void_stmt]
Instance Method Summary collapse
- #evaluate(expr_string) ⇒ Object
- #has_content? ⇒ Boolean
-
#initialize(clause_type, block, example, line_extractor) ⇒ NaturalAssertion
constructor
A new instance of NaturalAssertion.
- #message ⇒ Object
- #using_rspec_assertion? ⇒ Boolean
Constructor Details
#initialize(clause_type, block, example, line_extractor) ⇒ NaturalAssertion
Returns a new instance of NaturalAssertion.
32 33 34 35 36 37 38 |
# File 'lib/rspec/given/natural_assertion.rb', line 32 def initialize(clause_type, block, example, line_extractor) @clause_type = clause_type @block = block @example = example @line_extractor = line_extractor set_file_and_line end |
Instance Method Details
#evaluate(expr_string) ⇒ Object
59 60 61 |
# File 'lib/rspec/given/natural_assertion.rb', line 59 def evaluate(expr_string) eval_in_context(expr_string) end |
#has_content? ⇒ Boolean
46 47 48 |
# File 'lib/rspec/given/natural_assertion.rb', line 46 def has_content? assertion_sexp != VOID_SEXP end |
#message ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/rspec/given/natural_assertion.rb', line 50 def @output = "#{@clause_type} expression failed at #{source_line}\n" @output << "Failing expression: #{source.strip}\n" if @clause_type != "Then" explain_failure display_pairs(expression_value_pairs) @output << "\n" @output end |
#using_rspec_assertion? ⇒ Boolean
42 43 44 |
# File 'lib/rspec/given/natural_assertion.rb', line 42 def using_rspec_assertion? using_should? || using_expect? end |