Sha256: 33e36b3112f0224d43c21e28aa3baa38bf07ec4155e04ee418a0de04ed6376aa
Contents?: true
Size: 1.05 KB
Versions: 51
Compression:
Stored size: 1.05 KB
Contents
# # A Dummy service that may be useful for testing (manual or perhaps in automated # tests), that simply creates the responses you tell it to, after sleeping the # amount you tell it to. # # DummyService: # type: DummyService # priority: 3 # sleep: 4.5 # seconds # responses: # - service_type_value: fulltext # display_text: foo # url: http://google.com # - service_type_value: highlighted_link # display_text: bar # url: http://amazon.com # class DummyService < Service attr_accessor :responses, :sleep def initialize(config = {}) self.responses = [] self.sleep = 0 super end def service_types_generated responses.collect {|r| ServiceTypeValue[ r["service_type_value"] ]}.compact.uniq end def handle(request) ::Kernel.sleep( self.sleep ) if self.sleep responses.each do |response| request.add_service_response( { :service => self }.merge(response.symbolize_keys ) ) end return request.dispatched(self, true) end end
Version data entries
51 entries across 51 versions & 1 rubygems