thoughtbot/shoulda-matchers · error · QualifierOrderError

Using `set_flash` with the `now` qualifier and specifying `n

Error message

Using `set_flash` with the `now` qualifier and specifying `now` after other
qualifiers is no longer allowed.

You'll want to use `now` immediately after `set_flash`. For instance:

    # Valid
    should set_flash.now[:foo]
    should set_flash.now[:foo].to('bar')

    # Invalid
    should set_flash[:foo].now
    should set_flash[:foo].to('bar').now

What it means

Error "Using `set_flash` with the `now` qualifier and specifying `now` after other qualifiers is no longer allowed. You'll want to use `now` immediately after `set_flash`. For instance: # Valid should set_flash.now[:foo] should set_flash.now[:foo].to('bar') # Invalid should set_flash[:foo].now should set_flash[:foo].to('bar').now" thrown in thoughtbot/shoulda-matchers.

Source

Thrown at lib/shoulda/matchers/action_controller/set_flash_matcher.rb:177

          :description,
          :matches?,
          :failure_message,
          :failure_message_when_negated
        alias_method \
          :failure_message_for_should,
          :failure_message
        alias_method \
          :failure_message_for_should_not,
          :failure_message_when_negated

        def initialize
          store = FlashStore.future
          @underlying_matcher = SetSessionOrFlashMatcher.new(store)
        end

        def now
          if key || expected_value
            raise QualifierOrderError
          end

          store = FlashStore.now
          @underlying_matcher = SetSessionOrFlashMatcher.new(store)
          self
        end

        def in_context(context)
          underlying_matcher.in_context(context)
          self
        end

        def [](key)
          @key = key
          underlying_matcher[key]
          self
        end

View on GitHub (pinned to 79cdfbc326)

When it happens

Trigger: Thrown at lib/shoulda/matchers/action_controller/set_flash_matcher.rb:177 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of thoughtbot/shoulda-matchers@79cdfbc326 (2026-08-23). Data as JSON: /api/errors/315d96a96c061893. Report an issue: GitHub.