Class: Spec::Client::HttpClient
- Inherits:
-
Object
- Object
- Spec::Client::HttpClient
- Defined in:
- lib/spec/client/http_client.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #full_url(path) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(base_uri) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #new_session ⇒ Object
- #post(path, params = {}) ⇒ Object
Constructor Details
#initialize(base_uri) ⇒ HttpClient
Returns a new instance of HttpClient.
9 10 11 12 |
# File 'lib/spec/client/http_client.rb', line 9 def initialize(base_uri) @base_uri = base_uri @session = Http::Session.new(self) end |
Instance Attribute Details
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
7 8 9 |
# File 'lib/spec/client/http_client.rb', line 7 def base_uri @base_uri end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
7 8 9 |
# File 'lib/spec/client/http_client.rb', line 7 def session @session end |
Instance Method Details
#full_url(path) ⇒ Object
26 27 28 |
# File 'lib/spec/client/http_client.rb', line 26 def full_url(path) URI.join(base_uri, path).to_s end |
#get(path, params = {}) ⇒ Object
18 19 20 |
# File 'lib/spec/client/http_client.rb', line 18 def get(path, params = {}) session.get(full_url(path), params) end |
#new_session ⇒ Object
14 15 16 |
# File 'lib/spec/client/http_client.rb', line 14 def new_session() @session = Http::Session.new(self) end |
#post(path, params = {}) ⇒ Object
22 23 24 |
# File 'lib/spec/client/http_client.rb', line 22 def post(path, params = {}) session.post(full_url(path), params) end |