Skip to content

Minitest - ensure assertion does not raise if transition is invalid (return false instead) - #626

Open
marceloeloelo wants to merge 1 commit into
aasm:masterfrom
marceloeloelo:fix-refute-invalid-transition
Open

Minitest - ensure assertion does not raise if transition is invalid (return false instead)#626
marceloeloelo wants to merge 1 commit into
aasm:masterfrom
marceloeloelo:fix-refute-invalid-transition

Conversation

@marceloeloelo

Copy link
Copy Markdown

Given a state machine:

class Cleaner
  include AASM

  aasm do
    state :idle, initial: true
    state :cleaning

    event :clean do
      transitions from: :idle, to: :cleaning, guard: :cleaning_needed?
    end
  end

  def cleaning_needed?
    false
  end
end

A test that does:

cleaner = Cleaner.new
refute_transitions_from cleaner, :idle, to: :cleaning, on_event: :clean

will raise a AASM::InvalidTransition exception.

I believe a nicer behavior would be for the test to pass, instead.

@anilmaurya

Copy link
Copy Markdown
Member

Hi @marceloeloelo ,

Thank you for raising this PR. I agree test should pass instead of raising AASM::InvalidTransition exception.

Can you please add specs for this in minitest_matcher_test ?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants