summaryrefslogtreecommitdiff
path: root/spec/support/files.rb
blob: d0c5acd4ba057d93f760271e4c323b2139433e0f (plain)
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
# frozen_string_literal: true

RSpec.configure do |config|
  config.include(Module.new do
    def fixture_file(path)
      Pathname.new(__FILE__).parent.join('../fixtures', path)
    end

    def fixture_file_content(path)
      fixture_file(path).read
    end

    def license_file(id)
      fixture_file_content("spdx/text/#{id}.txt")
    end

    def to_path(path)
      Pathname.new(path)
    end

    def within_tmp_dir
      Dir.mktmpdir do |directory|
        Dir.chdir(directory) do
          yield Pathname.new(directory)
        end
      end
    end
  end)
end