Class: WebStub::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/webstub/registry.rb

Instance Method Summary collapse

Constructor Details

#initializeRegistry


3
4
5
# File 'lib/webstub/registry.rb', line 3

def initialize()
  @stubs = []
end

Instance Method Details

#add_stub(method, path) ⇒ Object


7
8
9
10
11
12
# File 'lib/webstub/registry.rb', line 7

def add_stub(method, path)
  stub = Stub.new(method, path)
  @stubs << stub

  stub
end

#resetObject


14
15
16
# File 'lib/webstub/registry.rb', line 14

def reset
  @stubs = []
end

#sizeObject


18
19
20
# File 'lib/webstub/registry.rb', line 18

def size
  @stubs.size
end

#stub_matching(method, url, options = {}) ⇒ Object


22
23
24
25
26
27
28
29
30
# File 'lib/webstub/registry.rb', line 22

def stub_matching(method, url, options={})
  @stubs.each do |stub|
    if stub.matches?(method, url, options)
      return stub
    end
  end

  nil
end