Class: Artemis::Adapters::TestAdapter
- Inherits:
-
Object
- Object
- Artemis::Adapters::TestAdapter
- Defined in:
- lib/artemis/adapters/test_adapter.rb
Instance Method Summary collapse
- #execute(**arguments) ⇒ Object
-
#initialize ⇒ TestAdapter
constructor
A new instance of TestAdapter.
- #multiplex(queries, context: {}) ⇒ Object
Constructor Details
#initialize ⇒ TestAdapter
Returns a new instance of TestAdapter.
19 20 |
# File 'lib/artemis/adapters/test_adapter.rb', line 19 def initialize(*) end |
Instance Method Details
#execute(**arguments) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/artemis/adapters/test_adapter.rb', line 34 def execute(**arguments) self.requests << Request.new(*arguments.values_at(:document, :operation_name, :variables, :context)) response = responses.detect do |mock| arguments[:operation_name] == mock.operation_name && (mock.arguments == :__unspecified__ || arguments[:variables] == mock.arguments) end response&.data || fake_response end |
#multiplex(queries, context: {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/artemis/adapters/test_adapter.rb', line 22 def multiplex(queries, context: {}) self.requests << Multiplex.new(queries, context) queries.map do |query| result = responses.detect do |mock| query[:operationName] == mock.operation_name && (mock.arguments == :__unspecified__ || query[:variables] == mock.arguments) end result&.data || fake_response end end |