Class: Reigns::WebClient

Inherits:
Object
  • Object
show all
Defined in:
lib/reigns/web_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(fake_dispatcher_servlet) ⇒ WebClient

Returns a new instance of WebClient.



7
8
9
# File 'lib/reigns/web_client.rb', line 7

def initialize(fake_dispatcher_servlet)
  @fake_dispatcher_servlet = fake_dispatcher_servlet
end

Instance Method Details

#delete(uri) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/reigns/web_client.rb', line 37

def delete(uri)
  http_request = HttpRequest.new do |r|
    r.method = 'DELETE'
    r.uri = uri
  end
  @fake_dispatcher_servlet.service(http_request)
end

#get(uri) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/reigns/web_client.rb', line 11

def get(uri)
  http_request = HttpRequest.new do |r|
    r.method = 'GET'
    r.uri = uri
  end
  @fake_dispatcher_servlet.service(http_request)
end

#post(uri) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/reigns/web_client.rb', line 28

def post(uri)
  http_request = HttpRequest.new do |r|
    r.method = 'POST'
    r.uri = uri
    yield r
  end
  @fake_dispatcher_servlet.service(http_request)
end

#put(uri) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/reigns/web_client.rb', line 19

def put(uri)
  http_request = HttpRequest.new do |r|
    r.method = 'PUT'
    r.uri = uri
    yield r
  end
  @fake_dispatcher_servlet.service(http_request)
end