Class: RSpec::Given::NaturalAssertion

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/given/natural_assertion.rb

Constant Summary collapse

VOID_SEXP =
[:void_stmt]

Instance Method Summary collapse

Constructor Details

#initialize(clause_type, block, example, line_extractor) ⇒ NaturalAssertion

Returns a new instance of NaturalAssertion.



18
19
20
21
22
23
# File 'lib/rspec/given/natural_assertion.rb', line 18

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

Returns:

  • (Boolean)


31
32
33
# File 'lib/rspec/given/natural_assertion.rb', line 31

def has_content?
  assertion_sexp != VOID_SEXP
end

#messageObject



35
36
37
38
39
40
41
42
# File 'lib/rspec/given/natural_assertion.rb', line 35

def message
  @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

Returns:

  • (Boolean)


27
28
29
# File 'lib/rspec/given/natural_assertion.rb', line 27

def using_rspec_assertion?
  using_should? || using_expect?
end