summaryrefslogtreecommitdiff
path: root/spec/support/fixture_file_helper.rb
blob: c7cd3deea2ecb2c5e49547ce28ed8c503c86b1eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module FixtureFileHelper
  def fixture_file_content(path, data = {})
    content = IO.read(fixture_file(path))
    return content unless path.end_with?('.erb')

    ERB
      .new(content)
      .result(OpenStruct.new(data).send(:binding))
  end

  def fixture_file(path)
    File.expand_path("spec/fixtures/#{path}")
  end
end