Typhoeus::Hydra::Stubbing::SharedMethods

Public Class Methods

extended(base) click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 34
def self.extended(base)
  class << base
    attr_accessor :stubs
  end
  base.stubs = []
end

Public Instance Methods

clear_stubs() click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 10
def clear_stubs
  self.stubs = []
end
find_stub_from_request(request) click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 18
def find_stub_from_request(request)
  stub_finders.each do |finder|
    if response = finder.call(request)
      mock = HydraMock.new(/.*/, :any)
      mock.and_return(response)
      return mock
    end
  end

  stubs.detect { |stub| stub.matches?(request) }
end
register_stub_finder(&block) click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 14
def register_stub_finder(&block)
  stub_finders << block
end
stub(method, url, options = {}) click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 5
def stub(method, url, options = {})
  stubs << HydraMock.new(url, method, options)
  stubs.last
end
stub_finders() click to toggle source
# File lib/typhoeus/hydra/stubbing.rb, line 30
def stub_finders
  @stub_finders ||= []
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.