Module: HttpTest::HttpMethods

Included in:
TestCase
Defined in:
lib/http-test/http_methods.rb

Overview

:status - HTTP response status code, such as 200 :body - the response body :response_headers

Defined Under Namespace

Modules: Response

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



73
74
75
# File 'lib/http-test/http_methods.rb', line 73

def response
  @response
end

Instance Method Details

#asset_redirect_to(url) ⇒ Object



75
76
77
78
# File 'lib/http-test/http_methods.rb', line 75

def asset_redirect_to(url)
  assert_equal(302, response.code)
  assert_equal(url, response.headers["location"])
end

#DELETE(path) ⇒ Object



69
70
71
# File 'lib/http-test/http_methods.rb', line 69

def DELETE(path)
  @response = Response.create Faraday.delete(url(path))
end

#GET(path) ⇒ Object



57
58
59
# File 'lib/http-test/http_methods.rb', line 57

def GET(path)
  @response = Response.create Faraday.get(url(path))
end

#HEAD(path) ⇒ Object

rubocop:disable Style/MethodName



53
54
55
# File 'lib/http-test/http_methods.rb', line 53

def HEAD(path)
  @response = Response.create Faraday.head(url(path))
end

#POST(path, body = {}) ⇒ Object



61
62
63
# File 'lib/http-test/http_methods.rb', line 61

def POST(path, body = {})
  @response = Response.create Faraday.post(url(path), body)
end

#PUT(path, body = {}) ⇒ Object



65
66
67
# File 'lib/http-test/http_methods.rb', line 65

def PUT(path, body = {})
  @response = Response.create Faraday.put(url(path), body)
end

#url(path) ⇒ Object



46
47
48
49
50
# File 'lib/http-test/http_methods.rb', line 46

def url(path)
  return path if path =~ /\Ahttp(s)?:/

  File.join(HttpTest.url_base, path)
end