Sha256: f67110ed7af4607b0ea51c644e0e1dc9eb1c55726a1f872120589ec6b811304c

Contents?: true

Size: 835 Bytes

Versions: 188

Compression:

Stored size: 835 Bytes

Contents

module WebMock

  class RequestRegistry
    include Singleton

    attr_accessor :requested_signatures

    def initialize
      reset!
    end

    def reset!
      self.requested_signatures = Util::HashCounter.new
    end

    def times_executed(request_pattern)
      self.requested_signatures.hash.select { |request_signature, times_executed|
        request_pattern.matches?(request_signature)
      }.inject(0) {|sum, (_, times_executed)| sum + times_executed }
    end

    def to_s
      if requested_signatures.hash.empty?
        "No requests were made."
      else
        text = ""
        self.requested_signatures.each do |request_signature, times_executed|
          text << "#{request_signature} was made #{times_executed} time#{times_executed == 1 ? '' : 's' }\n"
        end
        text
      end
    end

  end
end

Version data entries

188 entries across 177 versions & 14 rubygems

Version Path
webmock-2.0.2 lib/webmock/request_registry.rb
webmock-2.0.1 lib/webmock/request_registry.rb
webmock-2.0.0 lib/webmock/request_registry.rb
webmock-2.0.0.beta2 lib/webmock/request_registry.rb
webmock-1.24.6 lib/webmock/request_registry.rb
webmock-1.24.5 lib/webmock/request_registry.rb
webmock-1.24.4 lib/webmock/request_registry.rb
webmock-2.0.0.beta1 lib/webmock/request_registry.rb
webmock-1.24.3 lib/webmock/request_registry.rb
webmock-1.24.2 lib/webmock/request_registry.rb
webmock-1.24.1 lib/webmock/request_registry.rb
webmock-1.24.0 lib/webmock/request_registry.rb
webmock-1.23.0 lib/webmock/request_registry.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/webmock-1.20.4/lib/webmock/request_registry.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/webmock-1.20.4/lib/webmock/request_registry.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/webmock-1.20.4/lib/webmock/request_registry.rb
webmock-1.22.6 lib/webmock/request_registry.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/webmock-1.22.5/lib/webmock/request_registry.rb
webmock-1.22.5 lib/webmock/request_registry.rb
dwolla_swagger-1.0.6 vendor/bundle/ruby/2.2.0/gems/webmock-1.22.3/lib/webmock/request_registry.rb