class Dialers::MockedRoutesDefinition
Attributes
current_response[RW]
routes[RW]
Public Class Methods
new(&block)
click to toggle source
# File lib/dialers/mockable_caller.rb, line 26 def initialize(&block) self.routes = [] self.current_response = {} block.call(self) end
Public Instance Methods
get_route(http_method, url)
click to toggle source
# File lib/dialers/mockable_caller.rb, line 43 def get_route(http_method, url) routes.find do |route| route[:http_method] == http_method && route[:url] == url end end
respond_with(status, body)
click to toggle source
# File lib/dialers/mockable_caller.rb, line 38 def respond_with(status, body) current_response[:status] = status current_response[:body] = body end
to(http_method, url)
click to toggle source
# File lib/dialers/mockable_caller.rb, line 32 def to(http_method, url) self.current_response = route_from(http_method, url) routes << current_response self end
Private Instance Methods
route_from(http_method, url)
click to toggle source
# File lib/dialers/mockable_caller.rb, line 51 def route_from(http_method, url) { http_method: http_method, url: url } end