Sha256: f4d56cfc2c0462cd24537882385f3927b334ea6b172af1771c01763326cc3500
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
########################################## # tc_whereis.rb # # Test case for the File.whereis method. ########################################## base = File.basename(Dir.pwd) if base == "test" or base =~ /ptools/ Dir.chdir("..") if base == "test" $LOAD_PATH.unshift(Dir.pwd) $LOAD_PATH.unshift(Dir.pwd + "/lib") Dir.chdir("test") if Dir.pwd != "test" end require "test/unit" require "ptools" class TC_FileWhereis < Test::Unit::TestCase def setup # Change this to suit your system @expected_locs = ['/usr/local/bin/ruby','/opt/sfw/bin/ruby'] @expected_locs.push('/opt/bin/ruby', '/usr/bin/ruby') # MS Windows - change as needed if File::ALT_SEPARATOR @expected_locs = ["c:\\ruby\\bin\\ruby.exe"] end end def test_whereis_basic assert_respond_to(File, :whereis) assert_nothing_raised{ File.whereis("ruby") } assert_nothing_raised{ File.whereis("ruby","/usr/bin:/usr/local/bin") } assert_nothing_raised{ File.whereis("ruby"){} } end def test_whereis_expected_return_values assert_kind_of(Array, File.whereis("ruby")) assert_equal(true, @expected_locs.include?(File.whereis("ruby").first)) assert_equal(nil, File.whereis("blahblah")) end def test_whereis_expected_errors assert_raises(ArgumentError){ File.whereis } assert_raises(ArgumentError){ File.whereis("ruby","foo","bar") } end def teardown @expected_locs = nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ptools-1.0.0 | test/tc_whereis.rb |