File: test_long_path.rb

package info (click to toggle)
ruby-pathname2 1.8.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 340 kB
  • sloc: ruby: 2,033; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,202 bytes parent folder | download | duplicates (3)
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
40
41
########################################################################
# test_long_path.rb
#
# Test suite for the Pathname#long_path method
########################################################################
require 'test-unit'
require 'pathname2'

class TC_Pathname_LongPath < Test::Unit::TestCase
  def setup
    @abs_path = Pathname.new("C:\\PROGRA~1")
  end

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

  test "long_path returns the expected result" do
    assert_equal("C:\\Program Files", @abs_path.long_path)
  end

  test "long_path returns the same string if it's already long" do
    assert_equal("C:\\Program Files", Pathname.new("C:/Program Files").long_path)
  end

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

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

  def teardown
    @abs_path = nil
  end
end