Class: Keisanjaku::ProcedureChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/keisanjaku/procedure.rb

Constant Summary collapse

VALUE_TOLERANCE =
1e-9

Instance Method Summary collapse

Instance Method Details

#expected_events(plan) ⇒ Object



84
85
86
# File 'lib/keisanjaku/procedure.rb', line 84

def expected_events(plan)
  plan.steps.map { |step| ProcedureEvent.from_step(step) }
end

#matches?(plan, attempt) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
78
79
80
81
82
# File 'lib/keisanjaku/procedure.rb', line 75

def matches?(plan, attempt)
  return false if attempt.used_model

  expected = expected_events(plan)
  observed = observed_events(attempt)
  expected.length == observed.length &&
    expected.zip(observed).all? { |expected_event, observed_event| event_matches?(expected_event, observed_event) }
end

#observed_events(attempt) ⇒ Object



88
89
90
# File 'lib/keisanjaku/procedure.rb', line 88

def observed_events(attempt)
  attempt.actions.filter { |action| action.is_a?(ProcedureEvent) }
end