Sha256: 166a1bd7d930a2a43a21746d09fcbb81b59acd14d656ef1e0458016b0916c718

Contents?: true

Size: 1.71 KB

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
iostreams-1.10.3 test/path_test.rb
iostreams-1.10.2 test/path_test.rb
iostreams-1.10.1 test/path_test.rb
iostreams-1.10.0 test/path_test.rb
iostreams-1.9.0 test/path_test.rb
iostreams-1.8.0 test/path_test.rb
iostreams-1.7.0 test/path_test.rb
iostreams-1.6.2 test/path_test.rb
iostreams-1.6.1 test/path_test.rb
iostreams-1.6.0 test/path_test.rb
iostreams-1.5.1 test/path_test.rb
iostreams-1.5.0 test/path_test.rb
iostreams-1.4.0 test/path_test.rb
iostreams-1.3.3 test/path_test.rb
iostreams-1.3.2 test/path_test.rb
iostreams-1.3.1 test/path_test.rb
iostreams-1.3.0 test/path_test.rb
iostreams-1.2.1 test/path_test.rb
iostreams-1.2.0 test/path_test.rb
iostreams-1.1.1 test/path_test.rb