Sha256: 58dcb4660c8b1364c774ed5944c170ba619ab261cd4186b99c7455f7fdcbb595

Contents?: true

Size: 1.71 KB

Versions: 9

Compression:

Stored size: 1.71 KB

Contents

require_relative 'test_helper'

module IOStreams
  class PathTest < Minitest::Test
    describe IOStreams::Path do
      describe '.join' do
        let(:path) { IOStreams::Path.new('some_path') }

        it 'returns self when no elements' do
          assert_equal path.object_id, path.join.object_id
        end

        it 'adds element to path' do
          assert_equal ::File.join('some_path', 'test'), path.join('test').to_s
        end

        it 'adds paths to root' do
          assert_equal ::File.join('some_path', 'test', 'second', 'third'), path.join('test', 'second', 'third').to_s
        end

        it 'returns path and filename' do
          assert_equal ::File.join('some_path', 'file.xls'), path.join('file.xls').to_s
        end

        it 'adds elements to path' do
          assert_equal ::File.join('some_path', 'test', 'second', 'third', 'file.xls'), path.join('test', 'second', 'third', 'file.xls').to_s
        end

        it 'return path as sent in when full path' do
          assert_equal ::File.join('some_path', 'test', 'second', 'third', 'file.xls'), path.join('some_path', 'test', 'second', 'third', 'file.xls').to_s
        end
      end

      describe '#absolute?' do
        it 'true on absolute' do
          assert_equal true, IOStreams::Path.new('/a/b/c/d').absolute?
        end

        it 'false when not absolute' do
          assert_equal false, IOStreams::Path.new('a/b/c/d').absolute?
        end
      end

      describe '#relatve?' do
        it 'true on relative' do
          assert_equal true, IOStreams::Path.new('a/b/c/d').relative?
        end

        it 'false on absolute' do
          assert_equal false, IOStreams::Path.new('/a/b/c/d').relative?
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-1.1.0 test/path_test.rb
iostreams-1.0.0 test/path_test.rb
iostreams-1.0.0.beta7 test/path_test.rb
iostreams-1.0.0.beta6 test/path_test.rb
iostreams-1.0.0.beta5 test/path_test.rb
iostreams-1.0.0.beta4 test/path_test.rb
iostreams-1.0.0.beta3 test/path_test.rb
iostreams-1.0.0.beta2 test/path_test.rb
iostreams-1.0.0.beta test/path_test.rb