Class: EndStateMatchers::TransitionMatcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transition) ⇒ TransitionMatcher

Returns a new instance of TransitionMatcher.



9
10
11
12
13
14
15
16
# File 'lib/end_state_matchers.rb', line 9

def initialize(transition)
  @start_state, @end_state = transition.first
  @event = nil
  @guards = []
  @concluders = []
  @required_params = []
  @failure_messages = []
end

Instance Attribute Details

#concludersObject (readonly) Also known as: finalizers

Returns the value of attribute concluders.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def concluders
  @concluders
end

#end_stateObject (readonly)

Returns the value of attribute end_state.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def end_state
  @end_state
end

#eventObject (readonly)

Returns the value of attribute event.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def event
  @event
end

#failure_messagesObject (readonly)

Returns the value of attribute failure_messages.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def failure_messages
  @failure_messages
end

#guardsObject (readonly)

Returns the value of attribute guards.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def guards
  @guards
end

#machineObject (readonly)

Returns the value of attribute machine.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def machine
  @machine
end

#required_paramsObject (readonly)

Returns the value of attribute required_params.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def required_params
  @required_params
end

#start_stateObject (readonly)

Returns the value of attribute start_state.



7
8
9
# File 'lib/end_state_matchers.rb', line 7

def start_state
  @start_state
end

Instance Method Details

#descriptionObject



27
28
29
# File 'lib/end_state_matchers.rb', line 27

def description
  "have transition #{start_state} => #{end_state}"
end

#failure_messageObject



23
24
25
# File 'lib/end_state_matchers.rb', line 23

def failure_message
  failure_messages.join("\n")
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/end_state_matchers.rb', line 18

def matches?(actual)
  @machine = actual
  verify
end

#with_concluders(*concluders) ⇒ Object Also known as: with_concluder, with_finalizers



41
42
43
44
# File 'lib/end_state_matchers.rb', line 41

def with_concluders(*concluders)
  @concluders += Array(concluders).flatten
  self
end

#with_event(event) ⇒ Object



31
32
33
34
# File 'lib/end_state_matchers.rb', line 31

def with_event(event)
  @event = event
  self
end

#with_guards(*guards) ⇒ Object Also known as: with_guard



36
37
38
39
# File 'lib/end_state_matchers.rb', line 36

def with_guards(*guards)
  @guards += Array(guards).flatten
  self
end

#with_required_params(*params) ⇒ Object Also known as: with_required_param



46
47
48
49
# File 'lib/end_state_matchers.rb', line 46

def with_required_params(*params)
  @required_params += Array(params).flatten
  self
end