Skip to content

NoMethodError: undefined method `must_have_state' for an instance of Minitest::Expectation #875

@joshuacronemeyer

Description

@joshuacronemeyer

Describe the bug
Since I've updated from mintest 5.2.7 to using minitest 6.0.1 the must_have_state assertions stopped working.

The workaround I've done is to put this into my test_helper.rb

module Minitest::Expectations
  infect_an_assertion :assert_transitions_from, :must_transition_from, :do_not_flip
  infect_an_assertion :refute_transitions_from, :wont_transition_from, :do_not_flip
  infect_an_assertion :assert_transition_to_allowed, :must_allow_transition_to, :do_not_flip
  infect_an_assertion :refute_transition_to_allowed, :wont_allow_transition_to, :do_not_flip
  infect_an_assertion :assert_have_state, :must_have_state, :do_not_flip
  infect_an_assertion :refute_have_state, :wont_have_state, :do_not_flip
  infect_an_assertion :assert_event_allowed, :must_allow_event, :do_not_flip
  infect_an_assertion :refute_event_allowed, :wont_allow_event, :do_not_flip
end

To Reproduce
Steps to reproduce the behavior:

  1. In a rails application with minitest >= 6
  2. install aasm and configure test/test_helper.rb according to the aasm README
  3. run a test that uses must_have_state expectation
  4. See error NoMethodError: undefined method `must_have_state' for an instance of Minitest::Expectation

Expected behavior
Test runs without errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions