Class: Notion::Testing::Adapter
- Inherits:
-
Notion::Transport::Adapter
- Object
- Notion::Transport::Adapter
- Notion::Testing::Adapter
- Defined in:
- lib/notion/testing.rb
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
Instance Method Summary collapse
- #call(request) ⇒ Object
-
#initialize(*responses) ⇒ Adapter
constructor
A new instance of Adapter.
Constructor Details
#initialize(*responses) ⇒ Adapter
Returns a new instance of Adapter.
30 31 32 33 34 |
# File 'lib/notion/testing.rb', line 30 def initialize(*responses) super() @responses = responses @requests = [] end |
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
28 29 30 |
# File 'lib/notion/testing.rb', line 28 def requests @requests end |
Instance Method Details
#call(request) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/notion/testing.rb', line 36 def call(request) @requests << request response = @responses.shift || raise("no stubbed Notion response") return response if response.is_a?(Transport::Response) Transport::Response.new(status: 200, headers: {}, body: JSON.generate(response), request_id: nil, elapsed: 0) end |