module Minitest::Assertions
Public Instance Methods
_transitions_from?(object, from_state, args, options)
click to toggle source
# File lib/aasm/minitest/transition_from.rb, line 16 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
assert_event_allowed(object, event, options = {})
click to toggle source
# File lib/aasm/minitest/allow_event.rb, line 2 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
assert_have_state(object, state, options = {})
click to toggle source
# File lib/aasm/minitest/have_state.rb, line 2 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
assert_transition_to_allowed(object, to_state, options = {})
click to toggle source
# File lib/aasm/minitest/allow_transition_to.rb, line 2 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
assert_transitions_from(object, from_state, *args)
click to toggle source
# File lib/aasm/minitest/transition_from.rb, line 2 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
refute_event_allowed(object, event, options = {})
click to toggle source
# File lib/aasm/minitest/allow_event.rb, line 8 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
refute_have_state(object, state, options = {})
click to toggle source
# File lib/aasm/minitest/have_state.rb, line 8 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
refute_transition_to_allowed(object, to_state, options = {})
click to toggle source
# File lib/aasm/minitest/allow_transition_to.rb, line 8 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
refute_transitions_from(object, from_state, *args)
click to toggle source
# File lib/aasm/minitest/transition_from.rb, line 9 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