File: test_path_manager.rb

package info (click to toggle)
jekyll 4.3.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,356 kB
  • sloc: ruby: 16,765; javascript: 1,455; sh: 214; xml: 29; makefile: 9
file content (35 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

require "helper"

class TestPathManager < JekyllUnitTest
  context "PathManager" do
    setup do
      @source = Dir.pwd
    end

    should "return frozen copy of base if questionable path is nil" do
      assert_equal @source, Jekyll::PathManager.sanitized_path(@source, nil)
      assert Jekyll::PathManager.sanitized_path(@source, nil).frozen?
    end

    should "return a frozen copy of base if questionable path expands into the base" do
      assert_equal @source, Jekyll::PathManager.sanitized_path(@source, File.join(@source, "/"))
      assert Jekyll::PathManager.sanitized_path(@source, File.join(@source, "/")).frozen?
    end

    should "return a frozen string result" do
      if Jekyll::Utils::Platforms.really_windows?
        assert_equal(
          "#{@source}/_config.yml",
          Jekyll::PathManager.sanitized_path(@source, "E:\\_config.yml")
        )
      end
      assert_equal(
        "#{@source}/_config.yml",
        Jekyll::PathManager.sanitized_path(@source, "//_config.yml")
      )
      assert Jekyll::PathManager.sanitized_path(@source, "//_config.yml").frozen?
    end
  end
end