Sha256: c8997488dc6cd6bee31376264e754fa7d70b742fb3241de066f0e974fea20b73

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

########################################################################
# test_is_root.rb
#
# Test suite for the Pathname#root method
########################################################################
require 'test-unit'
require 'pathname2'

class TC_Pathname_IsRoot < Test::Unit::TestCase
  def setup
    @std_root = Pathname.new("C:\\")
    @unc_root = Pathname.new("\\\\foo\\bar")
  end

  test "root? basic functionality" do
    assert_respond_to(@std_root, :root?)
    assert_nothing_raised{ @std_root.root? }
    assert_boolean(@std_root.root?)
  end

  test "root? method returns true for root paths" do
    assert_true(@std_root.root?)
    assert_true(@unc_root.root?)
  end

  test "root? method returns false for non-root paths" do
    assert_false(Pathname.new("C:/foo").root?)
    assert_false(Pathname.new("//foo/bar/baz").root?)
    assert_false(Pathname.new("").root?)
  end

  test "root? method is not destructive" do
    str = 'C:/foo'
    path = Pathname.new(str)
    assert_nothing_raised{ path.root }
    assert_equal('C:\foo', path.to_s)
    assert_equal('C:/foo', str)
  end

  def teardown
    @std_root = nil
    @unc_root = nil
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pathname2-1.8.4 test/windows/test_is_root.rb
pathname2-1.8.3 test/windows/test_is_root.rb
pathname2-1.8.2 test/windows/test_is_root.rb
pathname2-1.8.1 test/windows/test_is_root.rb
pathname2-1.8.0 test/windows/test_is_root.rb
pathname2-1.7.4 test/windows/test_is_root.rb
pathname2-1.7.3 test/windows/test_is_root.rb
pathname2-1.7.2 test/windows/test_is_root.rb
pathname2-1.7.1 test/windows/test_is_root.rb
pathname2-1.7.0 test/windows/test_is_root.rb