Class: Spikard::Testing::TestClient
- Inherits:
-
Object
- Object
- Spikard::Testing::TestClient
- Defined in:
- lib/spikard/testing.rb
Overview
High level wrapper around the native test client.
Class Method Summary collapse
-
.new(app_or_native, config: nil) ⇒ Object
Factory method for creating test client from an app.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(native) ⇒ TestClient
constructor
A new instance of TestClient.
- #request(method, path, headers = nil, body = nil, **options) ⇒ Object
- #sse(path) ⇒ Object
- #websocket(path) ⇒ Object
Constructor Details
#initialize(native) ⇒ TestClient
Returns a new instance of TestClient.
49 50 51 |
# File 'lib/spikard/testing.rb', line 49 def initialize(native) @native = native end |
Class Method Details
.new(app_or_native, config: nil) ⇒ Object
Factory method for creating test client from an app
54 55 56 57 58 59 60 |
# File 'lib/spikard/testing.rb', line 54 def self.new(app_or_native, config: nil) # If passed a native client directly, use it return super(app_or_native) if app_or_native.is_a?(Spikard::Native::TestClient) # Otherwise, create test client from app Spikard::Testing.create_test_client(app_or_native, config: config) end |
Instance Method Details
#close ⇒ Object
80 81 82 |
# File 'lib/spikard/testing.rb', line 80 def close @native.close end |
#request(method, path, headers = nil, body = nil, **options) ⇒ Object
62 63 64 65 66 |
# File 'lib/spikard/testing.rb', line 62 def request(method, path, headers = nil, body = nil, **) payload = build_request_payload(headers, body, ) payload = @native.request(method.to_s.upcase, path, payload) Response.new(payload) end |