Sha256: 702317bd937ed1b6e8b2f836e3501420cb0648d99eee921d720209044e534d9e

Contents?: true

Size: 1.33 KB

Versions: 49

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require File.expand_path("../../test_helper", File.dirname(__FILE__))

module Coverband
  module Utils
    class RelativeFileConverterTest < ::Minitest::Test
      def test_convert
        converter = RelativeFileConverter.new(["/bar/tmp/"])
        assert_equal("./gracie.rb", converter.convert("/bar/tmp/gracie.rb"))
      end

      def test_convert_without_leading_forward_slash
        converter = RelativeFileConverter.new(["/foo/bar"])
        assert_equal("./file.rb", converter.convert("/foo/bar/file.rb"))
      end

      def test_multiple_roots
        converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
        assert_equal("./josie.rb", converter.convert("/foo/bar/josie.rb"))
      end

      def test_no_match
        converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
        assert_equal("/foo/josie.rb", converter.convert("/foo/josie.rb"))
      end

      def test_middle_path_match
        converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
        assert_equal("/tmp/foo/bar/josie.rb", converter.convert("/tmp/foo/bar/josie.rb"))
      end

      def test_already_relative_file
        converter = RelativeFileConverter.new(["/bar/tmp/", "/foo/bar/"])
        assert_equal("./foo/bar/josie.rb", converter.convert("./foo/bar/josie.rb"))
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
coverband-6.1.4 test/coverband/utils/relative_file_converter_test.rb
coverband-6.1.3 test/coverband/utils/relative_file_converter_test.rb
coverband-6.1.2 test/coverband/utils/relative_file_converter_test.rb
coverband-6.1.2.rc.1 test/coverband/utils/relative_file_converter_test.rb
coverband-6.1.1 test/coverband/utils/relative_file_converter_test.rb
coverband-6.1.0 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.3.rc.4 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.3.rc.3 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.3.rc.2 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.3.rc.1 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.2 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.1 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.1.rc.1 test/coverband/utils/relative_file_converter_test.rb
coverband-6.0.0 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.6.rc.6 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.3.2 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.6.rc.5 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.3.1 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.6.rc.4 test/coverband/utils/relative_file_converter_test.rb
coverband-5.2.6.rc.3 test/coverband/utils/relative_file_converter_test.rb