File: test_realpath.rb

package info (click to toggle)
ruby-pathname2 1.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 336 kB
  • sloc: ruby: 2,037; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
########################################################################
# test_realpath.rb
#
# Test suite for the Pathname#realpath method
########################################################################
require 'test-unit'
require 'pathname2'

class TC_Pathname_Realpath < Test::Unit::TestCase
  def setup
    @cwd  = Dir.pwd.tr('/', "\\")
    @path = Pathname.new(Dir.pwd)
  end

  test "realpath basic functionality" do
    assert_respond_to(@path, :realpath)
    assert_nothing_raised{ @path.realpath }
    assert_kind_of(String, @path.realpath)
  end

  test "realpath returns the expected result" do
    assert_equal(@cwd, @path.realpath)
  end

  test "realpath fails if the path does not exist" do
    assert_raise(Errno::ENOENT){ Pathname.new("C:/Bogus/AlsoBogus").realpath }
  end

  test "realpath method is not destructive" do
    str = 'C:/Program Files'
    assert_nothing_raised{ Pathname.new(str).realpath }
    assert_equal('C:/Program Files', str)
  end

  def teardown
    @cwd  = nil
    @path = nil
  end
end