Class: Dialers::MockedRoutesDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/dialers/mockable_caller.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ MockedRoutesDefinition

Returns a new instance of MockedRoutesDefinition.



26
27
28
29
30
# File 'lib/dialers/mockable_caller.rb', line 26

def initialize(&block)
  self.routes = []
  self.current_response = {}
  block.call(self)
end

Instance Method Details

#get_route(http_method, url) ⇒ Object



43
44
45
46
47
# 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) ⇒ Object



38
39
40
41
# 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) ⇒ Object



32
33
34
35
36
# 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