Module: Typhoeus::Hydra::Stubbing::SharedMethods

Included in:
Typhoeus::Hydra::Stubbing
Defined in:
lib/typhoeus/hydra/stubbing.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



18
19
20
21
22
23
# File 'lib/typhoeus/hydra/stubbing.rb', line 18

def self.extended(base)
  class << base
    attr_accessor :stubs
  end
  base.stubs = []
end

Instance Method Details

#clear_stubsObject



10
11
12
# File 'lib/typhoeus/hydra/stubbing.rb', line 10

def clear_stubs
  self.stubs = []
end

#find_stub_from_request(request) ⇒ Object



14
15
16
# File 'lib/typhoeus/hydra/stubbing.rb', line 14

def find_stub_from_request(request)
  stubs.detect { |stub| stub.matches?(request) }
end

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



5
6
7
8
# File 'lib/typhoeus/hydra/stubbing.rb', line 5

def stub(method, url, options = {})
  stubs << HydraMock.new(url, method, options)
  stubs.last
end