Sha256: 591f7fc00dcfd08b734a82efe6d4bec7af22e2ddb1674cfec88f2b670cc91c30

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

# @api private
# Validator for asserting whether a request was sent.
class WebTrap::Shared::Validators::RequestSentValidator
  # Initialize a new validator.
  def initialize
    @failed = true
  end

  # Whether no request was validated.
  #
  # @return [Boolean]
  def failed?
    @failed
  end

  # The message to be used if no request is validated.
  #
  # @return [String]
  def failure_message
    "expected block to send an HTTP request, but nothing was sent out"
  end

  # Validate a request.
  #
  # Since validators are run against intercepted requests this validator will
  # succeed for any request.
  #
  # @return [RequestSentValidator]
  #   This validator instance.
  def validate(_)
    @failed = false
    self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webtrap-0.1.1 lib/webtrap/shared/validators/request_sent_validator.rb
webtrap-0.1.0 lib/webtrap/shared/validators/request_sent_validator.rb