Module: Bidi2pdf::TestHelpers::SpecPathsHelper

Defined in:
lib/bidi2pdf/test_helpers/spec_paths_helper.rb

Overview

This submodule contains path-related helper methods and configuration for tests.

Instance Method Summary collapse

Instance Method Details

#fixture_dirString

Retrieves the directory path for Docker files.

Returns:

  • (String)

    the Docker directory path



11
12
13
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 11

def fixture_dir
  TestHelpers.configuration.fixture_dir
end

#fixture_fileString

Retrieves the directory path for fixtures.

Returns:

  • (String)

    the fixture directory path



17
18
19
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 17

def fixture_file(*)
  File.join(fixture_dir, *)
end

#random_tmp_dir(*dirs, prefix: nil) ⇒ String

Generates a random temporary directory path.

Parameters:

  • dirs (Array<String>)

    additional directory components to include in the path

  • prefix (String, nil) (defaults to: nil)

    an optional prefix for the directory name

Returns:

  • (String)

    the full path to the random temporary directory



44
45
46
47
48
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 44

def random_tmp_dir(*dirs, prefix: nil)
  base_dirs = [tmp_dir] + dirs.compact
  pfx = prefix || TestHelpers.configuration.prefix
  File.join(*base_dirs, "#{pfx}#{SecureRandom.hex(8)}")
end

#spec_dirString

Retrieves the directory path for specs.

Returns:

  • (String)

    the spec directory path



23
24
25
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 23

def spec_dir
  TestHelpers.configuration.spec_dir
end

#tmp_dirString

Retrieves the directory path for temporary files.

Returns:

  • (String)

    the temporary directory path



29
30
31
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 29

def tmp_dir
  TestHelpers.configuration.tmp_dir
end

#tmp_file(*parts) ⇒ String

Generates a path for a temporary file by joining the temporary directory with the given parts.

Parameters:

  • parts (Array<String>)

    the parts of the file path to join

Returns:

  • (String)

    the full path to the temporary file



36
37
38
# File 'lib/bidi2pdf/test_helpers/spec_paths_helper.rb', line 36

def tmp_file(*parts)
  File.join(tmp_dir, *parts)
end