summaryrefslogtreecommitdiff
path: root/spec/unit/terraform/parsers/lock_file_spec.rb
blob: 56eecd09a2727400b1dd2cfb6400cfc5c614d8eb (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.describe Spandx::Terraform::Parsers::LockFile do
  subject(:parser) { described_class.new }

  describe '#match?' do
    it { is_expected.to be_match(to_path('.terraform.lock.hcl')) }
    it { is_expected.not_to be_match(to_path('main.hcl')) }
    it { is_expected.not_to be_match(to_path('main.tf')) }
  end

  describe '#parse' do
    def build(name, version, path)
      Spandx::Core::Dependency.new(name: name, version: version, path: path)
    end

    context 'when parsing a .terraform.lock.hcl file' do
      subject { parser.parse(path) }

      let(:path) { fixture_file('terraform/simple/.terraform.lock.hcl') }

      specify do
        expect(subject).to match_array([
          build('registry.terraform.io/hashicorp/aws', '3.39.0', path)
        ])
      end
    end
  end
end