Skip to content

Commit

Permalink
add spec for delivery_adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
prog-supdex committed Sep 28, 2023
1 parent f881172 commit 8919b3b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/graphql/delivery_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

RSpec.describe GraphQL::AnyCable::DeliveryAdapter do
describe ".lookup" do
context "when config.delivery_method is valid" do
around do |ex|
old_value = GraphQL::AnyCable.config.delivery_method
GraphQL::AnyCable.config.delivery_method = :inline

ex.run

GraphQL::AnyCable.config.delivery_method = old_value
end

it "returns InlineAdapter" do
expect(GraphQL::Adapters::InlineAdapter).to receive(:new).with(executor_object: "object")

described_class.lookup(executor_object: "object")
end
end

context "when config.delivery_method is invalid" do
around do |ex|
old_value = GraphQL::AnyCable.config.delivery_method
GraphQL::AnyCable.config.delivery_method = :unknown_adapter

ex.run

GraphQL::AnyCable.config.delivery_method = old_value
end

it "raises an error" do
expect { described_class.lookup(executor_object: "object") }.to raise_error(
NameError,
/Delivery adapter :unknown_adapter haven't been found/,
)
end
end
end
end

0 comments on commit 8919b3b

Please sign in to comment.