Class: WebMock::RequestRegistry
- Inherits:
-
Object
- Object
- WebMock::RequestRegistry
- Includes:
- Singleton
- Defined in:
- lib/webmock/request_registry.rb
Instance Attribute Summary collapse
-
#requested_signatures ⇒ Object
Returns the value of attribute requested_signatures.
Instance Method Summary collapse
-
#initialize ⇒ RequestRegistry
constructor
A new instance of RequestRegistry.
- #reset! ⇒ Object
- #times_executed(request_pattern) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ RequestRegistry
Returns a new instance of RequestRegistry.
10 11 12 |
# File 'lib/webmock/request_registry.rb', line 10 def initialize reset! end |
Instance Attribute Details
#requested_signatures ⇒ Object
Returns the value of attribute requested_signatures.
8 9 10 |
# File 'lib/webmock/request_registry.rb', line 8 def requested_signatures @requested_signatures end |
Instance Method Details
#reset! ⇒ Object
14 15 16 |
# File 'lib/webmock/request_registry.rb', line 14 def reset! self.requested_signatures = Util::HashCounter.new end |
#times_executed(request_pattern) ⇒ Object
18 19 20 21 22 |
# File 'lib/webmock/request_registry.rb', line 18 def times_executed(request_pattern) self.requested_signatures.select do |request_signature| request_pattern.matches?(request_signature) end.inject(0) { |sum, (_, times_executed)| sum + times_executed } end |
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webmock/request_registry.rb', line 24 def to_s if requested_signatures.hash.empty? "No requests were made." else text = "".dup 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 |