Class: EndStateMatchers::TransitionMatcher
- Inherits:
-
Object
- Object
- EndStateMatchers::TransitionMatcher
- Defined in:
- lib/end_state_matchers.rb
Instance Attribute Summary collapse
-
#concluders ⇒ Object
(also: #finalizers)
readonly
Returns the value of attribute concluders.
-
#end_state ⇒ Object
readonly
Returns the value of attribute end_state.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#failure_messages ⇒ Object
readonly
Returns the value of attribute failure_messages.
-
#guards ⇒ Object
readonly
Returns the value of attribute guards.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#required_params ⇒ Object
readonly
Returns the value of attribute required_params.
-
#start_state ⇒ Object
readonly
Returns the value of attribute start_state.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(transition) ⇒ TransitionMatcher
constructor
A new instance of TransitionMatcher.
- #matches?(actual) ⇒ Boolean
- #with_concluders(*concluders) ⇒ Object (also: #with_concluder, #with_finalizers)
- #with_event(event) ⇒ Object
- #with_guards(*guards) ⇒ Object (also: #with_guard)
- #with_required_params(*params) ⇒ Object (also: #with_required_param)
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 = [] = [] end |
Instance Attribute Details
#concluders ⇒ Object (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_state ⇒ Object (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 |
#event ⇒ Object (readonly)
Returns the value of attribute event.
7 8 9 |
# File 'lib/end_state_matchers.rb', line 7 def event @event end |
#failure_messages ⇒ Object (readonly)
Returns the value of attribute failure_messages.
7 8 9 |
# File 'lib/end_state_matchers.rb', line 7 def end |
#guards ⇒ Object (readonly)
Returns the value of attribute guards.
7 8 9 |
# File 'lib/end_state_matchers.rb', line 7 def guards @guards end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
7 8 9 |
# File 'lib/end_state_matchers.rb', line 7 def machine @machine end |
#required_params ⇒ Object (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_state ⇒ Object (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
#description ⇒ Object
27 28 29 |
# File 'lib/end_state_matchers.rb', line 27 def description "have transition #{start_state} => #{end_state}" end |
#failure_message ⇒ Object
23 24 25 |
# File 'lib/end_state_matchers.rb', line 23 def .join("\n") end |
#matches?(actual) ⇒ 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 |