class StateMachineRspec::Matchers::States::Matcher

Attributes

failure_message[R]

Public Class Methods

new(states) click to toggle source
# File lib/matchers/states/matcher.rb, line 9
def initialize(states)
  @options = states.extract_options!
  @states = states
end

Public Instance Methods

description() click to toggle source
# File lib/matchers/states/matcher.rb, line 14
def description
  @states.map{ |event| event.inspect }.join(', ')
end
matches?(subject) click to toggle source
# File lib/matchers/states/matcher.rb, line 18
def matches?(subject)
  raise_if_multiple_values

  @subject = subject
  @introspector = StateMachineIntrospector.new(@subject,
                                               state_machine_scope)

  return false unless matches_states?(@states)
  @failure_message.nil?
end
matches_states?(states) click to toggle source
# File lib/matchers/states/matcher.rb, line 29
def matches_states?(states)
  raise NotImplementedError,
    "subclasses of #{self.class} must override matches_states?"
end

Protected Instance Methods

state_machine_scope() click to toggle source
# File lib/matchers/states/matcher.rb, line 36
def state_machine_scope
  @options.fetch(:on, nil)
end
state_value() click to toggle source
# File lib/matchers/states/matcher.rb, line 40
def state_value
  @options.fetch(:value, nil)
end

Private Instance Methods

raise_if_multiple_values() click to toggle source
# File lib/matchers/states/matcher.rb, line 46
def raise_if_multiple_values
  if @states.count > 1 && state_value
    raise ArgumentError, 'cannot make value assertions on ' +
                         'multiple states at once'
  end
end