Sha256: 8b04e1d9cd209fb27247e3ec3affeebff2028791b0862b00745e54389fbe314c

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

# -*- coding: utf-8 -*-
#
# @file 
# @brief
# @author ongaeshi
# @date   2011/03/08

require 'rubygems'
require 'test_helper'
require 'common/dbdir'
require 'file_test_utils'

class TestDbDir< Test::Unit::TestCase
  include CodeStock
  include FileTestUtils

  def test_db_default_dir
    assert_equal File.expand_path('~/.codestock'), db_default_dir

    ENV['CODESTOCK_DEFAULT_DIR'] = "~/DummyDir"
    assert_equal File.expand_path("~/DummyDir"), db_default_dir

    ENV['CODESTOCK_DEFAULT_DIR'] = nil
    ENV['CODESTOCK_DEFAULT_DIRR'] = "~/DummyDir"
    assert_equal File.expand_path('~/.codestock'), db_default_dir
  end

  def test_is_dbdir
    assert_equal false, dbdir?

    FileUtils.touch "grendb.yaml"
    assert_equal true, dbdir?
    
    FileUtils.mkdir_p 'damadame'
    FileUtils.touch "damadame/grendb.yaml"
    assert_equal true, dbdir?('damadame')
    assert_equal false, dbdir?('damadameyo')
  end

  def test_db_groonga_path
    assert_equal 'db/grendb.db', db_groonga_path 
    assert_equal '../db/grendb.db', db_groonga_path('..') 
    assert_equal '/Users/MrRuby/db/grendb.db', db_groonga_path('/Users/MrRuby')
  end

  def test_db_expand_groonga_path
    assert_equal File.expand_path('./db/grendb.db'), db_expand_groonga_path
  end

  def test_db_yaml_path
    assert_equal 'grendb.yaml', db_yaml_path 
    assert_equal '../grendb.yaml', db_yaml_path('..') 
    assert_equal '/Users/MrRuby/grendb.yaml', db_yaml_path('/Users/MrRuby') 
  end
end




Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codestock-0.1.4 test/test_dbdir.rb
codestock-0.1.3 test/test_dbdir.rb
codestock-0.1.2 test/test_dbdir.rb