module Minitest::Assertions
def _transitions_from?(object, from_state, args, options)
def _transitions_from?(object, from_state, args, options) state_machine_name = options[:on] object.aasm(state_machine_name).current_state = from_state.to_sym object.send(options[:on_event], *args) && options[:to].to_sym == object.aasm(state_machine_name).current_state end
def assert_event_allowed(object, event, options = {})
def assert_event_allowed(object, event, options = {}) state_machine_name = options.fetch(:on, :default) assert object.aasm(state_machine_name).may_fire_event?(event), "Expected that the event :#{event} would be allowed (on :#{state_machine_name})" end
def assert_have_state(object, state, options = {})
def assert_have_state(object, state, options = {}) state_machine_name = options.fetch(:on, :default) assert object.aasm(state_machine_name).current_state == state, "Expected that :#{object.aasm(state_machine_name).current_state} would be :#{state} (on :#{state_machine_name})" end
def assert_transition_to_allowed(object, to_state, options = {})
def assert_transition_to_allowed(object, to_state, options = {}) state_machine_name = options.fetch(:on, :default) assert object.aasm(state_machine_name).states(permitted: true).include?(to_state), "Expected that the state :#{to_state} would be reachable (on :#{state_machine_name})" end
def assert_transitions_from(object, from_state, *args)
def assert_transitions_from(object, from_state, *args) options = args.first options[:on] ||= :default assert _transitions_from?(object, from_state, args, options), "Expected transition state to :#{options[:to]} from :#{from_state} on event :#{options[:on_event]}, (on :#{options[:on]})" end
def refute_event_allowed(object, event, options = {})
def refute_event_allowed(object, event, options = {}) state_machine_name = options.fetch(:on, :default) refute object.aasm(state_machine_name).may_fire_event?(event), "Expected that the event :#{event} would not be allowed (on :#{state_machine_name})" end
def refute_have_state(object, state, options = {})
def refute_have_state(object, state, options = {}) state_machine_name = options.fetch(:on, :default) refute object.aasm(state_machine_name).current_state == state, "Expected that :#{object.aasm(state_machine_name).current_state} would be :#{state} (on :#{state_machine_name})" end
def refute_transition_to_allowed(object, to_state, options = {})
def refute_transition_to_allowed(object, to_state, options = {}) state_machine_name = options.fetch(:on, :default) refute object.aasm(state_machine_name).states(permitted: true).include?(to_state), "Expected that the state :#{to_state} would be reachable (on :#{state_machine_name})" end
def refute_transitions_from(object, from_state, *args)
def refute_transitions_from(object, from_state, *args) options = args.first options[:on] ||= :default refute _transitions_from?(object, from_state, args, options), "Expected transition state to :#{options[:to]} from :#{from_state} on event :#{options[:on_event]}, (on :#{options[:on]})" end