Sha256: 6d549fcf6dde96502c8b80c7565ef67e5fefa939b6b99963347a5aa9694305fd

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'minitest/autorun'
require_relative './test_helper'
require 'gistdoit/github/user_config'

module Github
  class ConfigTest < Minitest::Test
    def test_parses_yaml_from_file
      config_file_path = File.expand_path('../fixtures/config.yml', __FILE__)
      user_config = UserConfig.new(config_file_path)
      config_data = { 'username' => 'liamseanbrady', 'token' => 'ab12345' }

      assert_equal(config_data, user_config.all)
    end

    def test_returns_value_if_key_exists
      config_file_path = File.expand_path('../fixtures/config.yml', __FILE__)
      user_config = UserConfig.new(config_file_path)
      config_data = { 'username' => 'liamseanbrady', 'token' => 'ab12345' }

      assert_equal('ab12345', user_config['token'])
    end

    def test_returns_nil_if_no_method_exists_for_a_key
      config_file_path = File.expand_path('../fixtures/config.yml', __FILE__)
      user_config = UserConfig.new(config_file_path)
      config_data = { 'username' => 'liamseanbrady', 'token' => 'ab12345' }

      assert_equal(nil, user_config.method_that_does_not_exist)
    end

    def test_returns_correct_value_if_method_exists_for_a_key
      config_file_path = File.expand_path('../fixtures/config.yml', __FILE__)
      user_config = UserConfig.new(config_file_path)
      config_data = { 'username' => 'liamseanbrady', 'token' => 'ab12345' }

      assert_equal('liamseanbrady', user_config.username)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gistdoit-0.0.1 test/user_config_test.rb