# File lib/typhoeus/hydra/stubbing.rb, line 34 def self.extended(base) class << base attr_accessor :stubs end base.stubs = [] end
# File lib/typhoeus/hydra/stubbing.rb, line 10 def clear_stubs self.stubs = [] end
# 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(%r.*/, :any) mock.and_return(response) return mock end end stubs.detect { |stub| stub.matches?(request) } end
# File lib/typhoeus/hydra/stubbing.rb, line 14 def register_stub_finder(&block) stub_finders << block end
# File lib/typhoeus/hydra/stubbing.rb, line 5 def stub(method, url, options = {}) stubs << HydraMock.new(url, method, options) stubs.last end
# File lib/typhoeus/hydra/stubbing.rb, line 30 def stub_finders @stub_finders ||= [] end