Sha256: ad4c264820ccbd29fb49a2eab2fd9c3fd87c8b37d22cd177ea85eb758732ba4f

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

require 'test_helper'

module GraphQL
  module Client
    class ClientTest < Minitest::Test
      TestAdapter = Struct.new(:config) do
        def request(_query_string)
          Response.new('{ "data": { } }')
        end
      end

      def test_dump_schema_writes_a_schema_file_from_introspection_query
        adapter = TestAdapter.new(Config.new)

        Tempfile.create('temp_schema.json') do |f|
          Client.dump_schema(f, adapter: adapter)

          assert_equal(JSON.pretty_generate(data: {}), File.read(f))
        end
      end

      def test_new_instantiates_base
        client = Client.new(schema_fixture('schema.json'))

        assert_instance_of Base, client
      end

      def test_new_accepts_a_block_for_httpclient
        url = URI('http://example.com')

        client = Client.new(schema_fixture('schema.json')) do
          configure do |c|
            c.url = url
          end
        end

        assert_equal url, client.config.url
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphql_client-0.4.1 test/graphql_client/graphql_client_test.rb
graphql_client-0.3.3 test/graphql_client/graphql_client_test.rb