bblimke/webmock · error · ArgumentError

assert_requested with a stub object, doesn't accept blocks

Error message

assert_requested with a stub object, doesn't accept blocks

What it means

Error "assert_requested with a stub object, doesn't accept blocks" thrown in bblimke/webmock.

Source

Thrown at lib/webmock/api.rb:26

      WebMock::StubRegistry.instance.
        register_request_stub(WebMock::RequestStub.new(method, uri))
    end

    alias_method :stub_http_request, :stub_request

    def a_request(method, uri)
      WebMock::RequestPattern.new(method, uri)
    end

    class << self
      alias :request :a_request
    end

    def assert_requested(*args, &block)
      if not args[0].is_a?(WebMock::RequestStub)
        args = convert_uri_method_and_options_to_request_and_options(args[0], args[1], args[2], &block)
      elsif block
        raise ArgumentError, "assert_requested with a stub object, doesn't accept blocks"
      end
      assert_request_requested(*args)
    end

    def assert_not_requested(*args, &block)
      if not args[0].is_a?(WebMock::RequestStub)
        args = convert_uri_method_and_options_to_request_and_options(args[0], args[1], args[2], &block)
      elsif block
        raise ArgumentError, "assert_not_requested with a stub object, doesn't accept blocks"
      end
      assert_request_not_requested(*args)
    end
    alias refute_requested assert_not_requested

    # Similar to RSpec::Mocks::ArgumentMatchers#hash_including()
    #
    # Matches a hash that includes the specified key(s) or key/value pairs.
    # Ignores any additional keys.

View on GitHub (pinned to b187df8827)

When it happens

Trigger: Thrown at lib/webmock/api.rb:26 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bblimke/webmock@b187df8827 (2026-08-23). Data as JSON: /api/errors/8e19eda195175612. Report an issue: GitHub.