Class: StateMachinesRspec::Matchers::States::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/matchers/states/matcher.rb

Direct Known Subclasses

HaveStateMatcher, RejectStateMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(states) ⇒ Matcher

Returns a new instance of Matcher.



9
10
11
12
# File 'lib/matchers/states/matcher.rb', line 9

def initialize(states)
  @options = states.extract_options!
  @states = states
end

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



7
8
9
# File 'lib/matchers/states/matcher.rb', line 7

def failure_message
  @failure_message
end

Instance Method Details

#descriptionObject



14
15
16
# File 'lib/matchers/states/matcher.rb', line 14

def description
  @states.map{ |event| event.inspect }.join(', ')
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
# File 'lib/matchers/states/matcher.rb', line 18

def matches?(subject)
  raise_if_multiple_values

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

  return false unless matches_states?(@states)
  @failure_message.nil?
end

#matches_states?(states) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


29
30
31
32
# File 'lib/matchers/states/matcher.rb', line 29

def matches_states?(states)
  raise NotImplementedError,
    "subclasses of #{self.class} must override matches_states?"
end