class StateMachinesRspec::Matchers::HaveStateMatcher
Public Instance Methods
description()
click to toggle source
Calls superclass method
StateMachinesRspec::Matchers::States::Matcher#description
# File lib/matchers/states/have_state.rb, line 17 def description message = super message << " == #{state_value.inspect}" if state_value message << " on #{state_machine_scope.inspect}" if state_machine_scope "have #{message}" end
matches_states?(states)
click to toggle source
# File lib/matchers/states/have_state.rb, line 11 def matches_states?(states) return false if undefined_states? return false if incorrect_value? @failure_message.nil? end
Private Instance Methods
incorrect_value?()
click to toggle source
# File lib/matchers/states/have_state.rb, line 36 def incorrect_value? if state_value && @introspector.state(@states.first).value != state_value @failure_message = "Expected #{@states.first} to have value #{state_value}" true end false end
undefined_states?()
click to toggle source
# File lib/matchers/states/have_state.rb, line 26 def undefined_states? undefined_states = @introspector.undefined_states(@states) unless undefined_states.empty? @failure_message = "Expected #{@introspector.state_machine_attribute} " + "to allow states: #{undefined_states.join(', ')}" end !undefined_states.empty? end