File: helpers.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (41 lines) | stat: -rw-r--r-- 925 bytes parent folder | download
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
36
37
38
39
40
41
# frozen_string_literal: true

module GitlabBackupHelpers
  FakeContext = Struct.new(:gitlab_version, :backup_basedir, :env, keyword_init: true)

  # Specs basepath
  # @return [Pathname]
  def spec_path
    Pathname.new(__dir__).join('..').expand_path
  end

  # Fixtures basepath
  # @return [Pathname]
  def fixtures_path
    spec_path.join('fixtures')
  end

  # Temporary folder basepath inside project
  # @return [Pathname]
  def temp_path
    spec_path.join('..', 'tmp').expand_path
  end

  def stub_env(var, return_value)
    stub_const('ENV', ENV.to_hash.merge(var => return_value))
  end

  def build_fake_context
    FakeContext.new(
      gitlab_version: '16.10',
      backup_basedir: temp_path.join('backups'),
      env: ActiveSupport::EnvironmentInquirer.new('test')
    )
  end
end

RSpec.configure do |config|
  config.include GitlabBackupHelpers
  # from gitlab-rspec
  config.include NextInstanceOf
end