rspec-terraform 0.1.0.pre.16 → 0.1.0.pre.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec/terraform/matchers/include_output_change.rb +40 -3
- data/lib/rspec/terraform/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a78765d5eecf1940eb733e53740d9835587ee3f19647222b2b7e3e594b72a23
|
4
|
+
data.tar.gz: 328c9a749a876711521c9581f0d75a2d9c9ede2821ddbb6012c0acb79869c852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61f34656cba5a4fe108338284345256cc9c91cc2939d9a4451ef8a30c08ca978e1ff0a087d2f1b238f88bed7b3a80ef31fa41fc1e610219ec962b65d6fbb1519
|
7
|
+
data.tar.gz: 1ae1c88f42592e288f7a4e78681479582b1e42baefd25cdb2bbc25d24e5fb586b0a1186ff418628982bc70bf21cd34e6f48d1f6c18f4d76c38a02d1328fe7ab9
|
data/Gemfile.lock
CHANGED
@@ -4,17 +4,19 @@ module RSpec
|
|
4
4
|
module Terraform
|
5
5
|
module Matchers
|
6
6
|
class IncludeOutputChange
|
7
|
-
attr_reader :definition
|
7
|
+
attr_reader :definition, :value
|
8
8
|
|
9
9
|
def initialize(definition)
|
10
10
|
@definition = definition
|
11
|
+
@value = nil
|
11
12
|
end
|
12
13
|
|
13
14
|
def matches?(plan)
|
14
|
-
!
|
15
|
+
!value_matches(plan).empty?
|
15
16
|
end
|
16
17
|
|
17
|
-
def with_value(
|
18
|
+
def with_value(value)
|
19
|
+
@value = maybe_box_value(value)
|
18
20
|
self
|
19
21
|
end
|
20
22
|
|
@@ -23,6 +25,41 @@ module RSpec
|
|
23
25
|
def definition_matches(plan)
|
24
26
|
plan.output_changes_matching(definition)
|
25
27
|
end
|
28
|
+
|
29
|
+
def value_matches(plan)
|
30
|
+
matches = definition_matches(plan)
|
31
|
+
return matches unless value
|
32
|
+
|
33
|
+
expected = value_matcher(value)
|
34
|
+
|
35
|
+
matches.filter do |output_change|
|
36
|
+
change = output_change.change
|
37
|
+
after = change.after_object
|
38
|
+
actual = resolved_value(value, after)
|
39
|
+
|
40
|
+
expected&.matches?(actual)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def maybe_box_value(value)
|
45
|
+
if value.respond_to?(:matches?)
|
46
|
+
value
|
47
|
+
else
|
48
|
+
RubyTerraform::Models::Objects.box(value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def value_matcher(expected)
|
53
|
+
return expected if expected.respond_to?(:matches?)
|
54
|
+
|
55
|
+
RSpec::Matchers::BuiltIn::Eq.new(expected)
|
56
|
+
end
|
57
|
+
|
58
|
+
def resolved_value(expected, actual)
|
59
|
+
return actual&.unbox if expected.respond_to?(:matches?)
|
60
|
+
|
61
|
+
actual
|
62
|
+
end
|
26
63
|
end
|
27
64
|
end
|
28
65
|
end
|