Sha256: 8deab3dec5152e1048fb69b84d755801f595be037b7fd9972e8eba52aa6361ba

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

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

require 'rubygems'
require File.join(File.dirname(__FILE__), "test_helper")
require File.join(File.dirname(__FILE__), "../lib/common/dbdir")
require File.join(File.dirname(__FILE__), "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

2 entries across 2 versions & 1 rubygems

Version Path
codestock-0.1.1 test/test_dbdir.rb
codestock-0.1.0 test/test_dbdir.rb