Class: StateMachineChecker::RspecMatchers::SatisfyMatcher

Inherits:
Object
  • Object
show all
Includes:
StateMachineChecker
Defined in:
lib/state_machine_checker/rspec_matchers.rb

Constant Summary

Constants included from StateMachineChecker

VERSION

Instance Method Summary collapse

Methods included from StateMachineChecker

#build_labeled_machine, #check_satisfied

Constructor Details

#initialize(formula) ⇒ SatisfyMatcher

Returns a new instance of SatisfyMatcher.


12
13
14
# File 'lib/state_machine_checker/rspec_matchers.rb', line 12

def initialize(formula)
  @formula = formula
end

Instance Method Details

#descriptionObject


16
17
18
# File 'lib/state_machine_checker/rspec_matchers.rb', line 16

def description
  "satisfy \"#{formula}\""
end

#diffable?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/state_machine_checker/rspec_matchers.rb', line 20

def diffable?
  false
end

#failure_messageObject


30
31
32
33
34
35
# File 'lib/state_machine_checker/rspec_matchers.rb', line 30

def failure_message
  <<~MESSAGE
    Expected state machine for #{machine_name} to satisfy "#{formula}" but it does not.
    Counterexample: #{result.counterexample}
  MESSAGE
end

#failure_message_when_negatedObject


37
38
39
40
41
42
# File 'lib/state_machine_checker/rspec_matchers.rb', line 37

def failure_message_when_negated
  <<~MESSAGE
    Expected state machine for #{machine_name} not to satisfy "#{formula}" but it does.
    Witness: #{result.witness}
  MESSAGE
end

#matches?(instance_generator) ⇒ Boolean

Returns:

  • (Boolean)

24
25
26
27
28
# File 'lib/state_machine_checker/rspec_matchers.rb', line 24

def matches?(instance_generator)
  @instance_generator = instance_generator
  @result = check_satisfied(formula, instance_generator)
  @result.satisfied?
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)

44
45
46
# File 'lib/state_machine_checker/rspec_matchers.rb', line 44

def supports_block_expectations?
  true
end