summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-05-09 13:38:11 -0600
committermo khan <mo@mokhan.ca>2021-05-09 13:38:11 -0600
commit1858fd10cb0989ea9155f13ba761c36cd92963cc (patch)
tree4384f1514ede51e696f50ced7a73e8930e450623 /spec/unit
parent10c6d265a3bb0bbe0aa9169f6ecd47abd7d1f5ab (diff)
[wip] parse arguments
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/terraform/parsers/hcl_spec.rb35
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/unit/terraform/parsers/hcl_spec.rb b/spec/unit/terraform/parsers/hcl_spec.rb
index 87acd4a..fc4a29f 100644
--- a/spec/unit/terraform/parsers/hcl_spec.rb
+++ b/spec/unit/terraform/parsers/hcl_spec.rb
@@ -11,13 +11,18 @@ RSpec.describe Spandx::Terraform::Parsers::Hcl do
<<~HCL
provider "registry.terraform.io/hashicorp/aws" {
version = "3.39.0"
+ constraints = "~> 3.27"
}
HCL
end
specify { expect(subject[0].dig(:provider, :name).to_s).to eql('registry.terraform.io/hashicorp/aws') }
- specify { expect(subject[0].dig(:provider, :version).to_s).to eql('3.39.0') }
+ specify { expect(subject[1].dig(:provider, :version).to_s).to eql('3.39.0') }
+ specify { expect(subject[2].dig(:provider, :constraints).to_s).to eql('~> 3.27') }
specify { expect(subject).to be_truthy }
+ specify do
+ puts subject
+ end
end
end
@@ -53,6 +58,34 @@ RSpec.describe Spandx::Terraform::Parsers::Hcl do
end
end
+ describe '#constraint_assignment' do
+ subject { parser.constraint_assignment }
+
+ [
+ 'constraints = ">= 3"',
+ 'constraints = ">= 3.27"',
+ 'constraints = ">= 3.27.0"',
+ 'constraints = "~> 3"',
+ 'constraints = "~> 3.27"',
+ 'constraints = "~> 3.27.0"',
+ ].each do |raw|
+ specify { expect(subject).to parse(raw) }
+ end
+ end
+
+ describe '#version_constraint' do
+ [
+ '~> 3',
+ '~> 3.27',
+ '~> 3.27.0',
+ '>= 1.2.0',
+ '>= 1.20',
+ '>= 10',
+ ].each do |raw|
+ specify { expect(parser.version_constraint).to parse(raw) }
+ end
+ end
+
(('a'..'z').to_a + ('A'..'Z').to_a).each do |letter|
specify { expect(parser.alpha).to parse(letter) }
end