Sha256: f0dbdb105b0da8269f89f0ea59e36e1dc2f9622ea2b0d81056bfdec995b5449a

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

require "webmock/rspec"

module WebTrap
  module RSpec
    module Matchers
      class SendRequest
        def matches?(transmission_proc)
          perform_transmission(transmission_proc)
          request_sent?
        end

        def failure_message
          "expected block to send an HTTP request, but nothing was sent out"
        end

        def supports_block_expectations?
          true
        end

        def with_xml(xml)
          SendRequestWithXml.new(xml)
        end

        private

        def perform_transmission(transmission_proc)
          WebMock.disable_net_connect!
          begin
            transmission_proc.call
            @request_sent = false
          rescue WebMock::NetConnectNotAllowedError
            @request_sent = true
          end
          WebMock.allow_net_connect!
        end

        def request_sent?
          @request_sent
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webtrap-0.0.0 lib/webtrap/rspec/matchers/send_request.rb