Sha256: 300f305288fcc2000e2605291e478e5be94168de7216982be59d7b03d9f633bb

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

########################################################################
# test_pstrip.rb
#
# Test suite for the Pathname#pstrip method
########################################################################
require 'test-unit'
require 'pathname2'

class TC_Pathname_Pstrip < Test::Unit::TestCase
  def setup
    @path = Pathname.new("C:/Program Files////")
  end

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

  test "pstrip returns expected result for path with trailing slashes" do
    assert_equal("C:\\Program Files", @path.pstrip)
    assert_equal("C:\\Program Files", Pathname.new("C:\\Program Files\\\\").pstrip)
    assert_equal("C:\\Program Files", Pathname.new("C:\\Program Files//\\").pstrip)
  end

  test "pstrip returns the path as is if it does not contain a trailing slash" do
    assert_equal("C:\\Program Files", Pathname.new("C:\\Program Files").pstrip)
    assert_equal("", Pathname.new("").pstrip)
  end

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

  def teardown
    @abs_path = nil
    @unc_path = nil
    @rel_path = nil
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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