Sha256: a5ebc270301e4870fd9b405288ccad9ecf098763ed1402002ac3862a0df60bce

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'

module GraphQL
  module Client
    class ConfigTest < Minitest::Test
      def test_initialize_overrides_defaults
        config = Config.new(
          debug: true,
          password: 'foo',
          per_page: 5,
        )

        assert config.debug
        assert_equal({}, config.headers)
        assert_equal 'foo', config.password
        assert_equal 5, config.per_page
        assert_nil config.username
      end

      def test_initialize_parses_url_as_uri
        config = Config.new(url: 'http://example.com')

        assert_kind_of URI, config.url
      end

      def test_initialize_accepts_open_timeout_in_seconds
        config = Config.new(open_timeout: 2)
        assert_equal 2, config.open_timeout
      end

      def test_initialize_accepts_read_timeout_in_seconds
        config = Config.new(read_timeout: 5)
        assert_equal 5, config.read_timeout
      end

      def test_setting_open_timeout_after_initialization
        config = Config.new
        config.open_timeout = 2

        assert_equal 2, config.open_timeout
      end

      def test_setting_read_timeout_after_initialization
        config = Config.new
        config.read_timeout = 5

        assert_equal 5, config.read_timeout
      end

      def test_opent_timeout_is_5_seconds_when_not_set
        config = Config.new
        assert_equal 5, config.open_timeout
      end

      def test_read_timeout_is_5_seconds_when_not_set
        config = Config.new
        assert_equal 5, config.read_timeout
      end

      def test_url_writer_coerces_to_uri
        config = Config.new
        config.url = 'http://example.com'

        assert_kind_of URI, 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/config_test.rb
graphql_client-0.3.3 test/graphql_client/config_test.rb