Module: MiniTest::Assertions
- Defined in:
- lib/aasm/minitest/allow_transition_to.rb,
lib/aasm/minitest/transition_from.rb,
lib/aasm/minitest/allow_event.rb,
lib/aasm/minitest/have_state.rb
Instance Method Summary collapse
- #_transitions_from?(object, from_state, args, options) ⇒ Boolean
- #assert_event_allowed(object, event, options = {}) ⇒ Object
- #assert_have_state(object, state, options = {}) ⇒ Object
- #assert_transition_to_allowed(object, to_state, options = {}) ⇒ Object
- #assert_transitions_from(object, from_state, *args) ⇒ Object
- #refute_event_allowed(object, event, options = {}) ⇒ Object
- #refute_have_state(object, state, options = {}) ⇒ Object
- #refute_transition_to_allowed(object, to_state, options = {}) ⇒ Object
- #refute_transitions_from(object, from_state, *args) ⇒ Object
Instance Method Details
#_transitions_from?(object, from_state, args, options) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/aasm/minitest/transition_from.rb', line 16 def _transitions_from?(object, from_state, args, ) state_machine_name = [:on] object.aasm(state_machine_name).current_state = from_state.to_sym object.send([:on_event], *args) && [:to].to_sym == object.aasm(state_machine_name).current_state end |
#assert_event_allowed(object, event, options = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/aasm/minitest/allow_event.rb', line 2 def assert_event_allowed(object, event, = {}) state_machine_name = .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 = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/aasm/minitest/have_state.rb', line 2 def assert_have_state(object, state, = {}) state_machine_name = .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 = {}) ⇒ Object
2 3 4 5 6 |
# File 'lib/aasm/minitest/allow_transition_to.rb', line 2 def assert_transition_to_allowed(object, to_state, = {}) state_machine_name = .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) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/aasm/minitest/transition_from.rb', line 2 def assert_transitions_from(object, from_state, *args) = args.first [:on] ||= :default assert _transitions_from?(object, from_state, args, ), "Expected transition state to :#{[:to]} from :#{from_state} on event :#{[:on_event]}, (on :#{[:on]})" end |
#refute_event_allowed(object, event, options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/aasm/minitest/allow_event.rb', line 8 def refute_event_allowed(object, event, = {}) state_machine_name = .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 = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/aasm/minitest/have_state.rb', line 8 def refute_have_state(object, state, = {}) state_machine_name = .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 = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/aasm/minitest/allow_transition_to.rb', line 8 def refute_transition_to_allowed(object, to_state, = {}) state_machine_name = .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) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/aasm/minitest/transition_from.rb', line 9 def refute_transitions_from(object, from_state, *args) = args.first [:on] ||= :default refute _transitions_from?(object, from_state, args, ), "Expected transition state to :#{[:to]} from :#{from_state} on event :#{[:on_event]}, (on :#{[:on]})" end |