Sha256: 0edcdb9a2bcf78dfb85609b559df10555151636fa8a578ec4582c764e77a91b2

Contents?: true

Size: 1.65 KB

Versions: 9

Compression:

Stored size: 1.65 KB

Contents

describe Artemis::GraphQLEndpoint do
  describe ".lookup" do
    it "raises an exception when the service is missing" do
      expect { Artemis::GraphQLEndpoint.lookup(:does_not_exit) }.to raise_error(Artemis::EndpointNotFound)
    end
  end

  it "can register an endpoint" do
    endpoint = Artemis::GraphQLEndpoint.register!(:github, url: "https://api.github.com/graphql")

    expect(endpoint.url).to eq("https://api.github.com/graphql")
    expect(endpoint.connection).to be_instance_of(Artemis::Adapters::NetHttpAdapter)
  end

  it "can look up a registered endpoint" do
    Artemis::GraphQLEndpoint.register!(:github, url: "https://api.github.com/graphql")

    endpoint = Artemis::GraphQLEndpoint.lookup(:github)

    expect(endpoint.url).to eq("https://api.github.com/graphql")
    expect(endpoint.connection).to be_instance_of(Artemis::Adapters::NetHttpAdapter) # Not a fan of this test but for now

    # FIXME: This #schema method makes a network call.
    # expect(endpoint.schema).to eq(...)
  end

  it "can register an endpoint with options" do
    options = {
      adapter: :test,
      timeout: 10,
      # schema_path: nil,
      pool_size: 25,
    }

    endpoint = Artemis::GraphQLEndpoint.register!(:github, url: "https://api.github.com/graphql", **options)

    expect(endpoint.url).to eq("https://api.github.com/graphql")
    expect(endpoint.timeout).to eq(10)
    expect(endpoint.pool_size).to eq(25)
    expect(endpoint.connection).to be_instance_of(Artemis::Adapters::TestAdapter) # Not a fan of this test but for now

    # FIXME: needs an example schema (and specify the :schema_path option) to test this.
    # expect(endpoint.schema).to eq(...)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
artemis-0.8.0 spec/endpoint_spec.rb
artemis-0.7.0 spec/endpoint_spec.rb
artemis-0.6.0 spec/endpoint_spec.rb
artemis-0.5.2 spec/endpoint_spec.rb
artemis-0.5.1 spec/endpoint_spec.rb
artemis-0.5.0 spec/endpoint_spec.rb
artemis-0.4.0 spec/endpoint_spec.rb
artemis-0.2.0 spec/endpoint_spec.rb
artemis-0.1.0 spec/endpoint_spec.rb