Sha256: f67110ed7af4607b0ea51c644e0e1dc9eb1c55726a1f872120589ec6b811304c

Contents?: true

Size: 835 Bytes

Versions: 187

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

187 entries across 176 versions & 14 rubygems

Version Path
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
cloudsmith-api-0.30.7 vendor/bundle/ruby/2.3.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
color_me_shop-1.0.0 vendor/bundle/ruby/2.5.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/webmock-1.24.6/lib/webmock/request_registry.rb
logstash-output-icinga-1.1.0 vendor/jruby/2.3.0/gems/webmock-2.3.2/lib/webmock/request_registry.rb