Sha256: d64d98bc97cd9cce6a5c827051e0337c4b2893d23888da63d959faca135c887b

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

require_relative 'test_helper'

module IOStreams
  class PathTest < Minitest::Test
    describe IOStreams do
      describe '.root' do
        it 'return default path' do
          path = ::File.expand_path(::File.join(__dir__, '../tmp/default'))
          assert_equal path, IOStreams.root.to_s
        end

        it 'return downloads path' do
          path = ::File.expand_path(::File.join(__dir__, '../tmp/downloads'))
          assert_equal path, IOStreams.root(:downloads).to_s
        end
      end

      describe '.path' do
        it 'returns path' do
          assert_equal IOStreams.root.to_s, IOStreams.join.to_s
        end

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

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

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

        it 'adds path to root and filename' do
          path = ::File.join(IOStreams.root.to_s, 'test', 'file.xls')
          assert_equal path, IOStreams.join('test', 'file.xls').to_s
        end

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

        it 'return path as sent in when full path' do
          path = ::File.join(IOStreams.root.to_s, 'file.xls')
          assert_equal path, IOStreams.join(path).to_s
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
iostreams-0.20.3 test/path_test.rb
iostreams-0.20.2 test/path_test.rb
iostreams-0.20.1 test/path_test.rb