rspec-terraform 0.1.0.pre.17 → 0.1.0.pre.18
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 +58 -2
- 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: 6bea553c61f70c6bd7bf4bdedca8b618a00539e8bfb1de8234e9771c8462c1ca
|
4
|
+
data.tar.gz: e3ef056ecdf300bb9c9ce9656090a4ac93703d5346ba36e0f2c3f43885f927da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68c9235ad0a528f15f1e0801681210561cecf4070b69276fe2a28436e28b3f5748728220382b3e87950a1959a46ce912be09d6b300f94732bf50ebe3a78cfc9
|
7
|
+
data.tar.gz: 61b756e071fba7355d294552d042b0d855ac1ca18021f1b06c594b3b3e2fad05d5d53668580880911db3e6c103d5b46579f1a8e28f6d2fc54c08a46014772696
|
data/Gemfile.lock
CHANGED
@@ -4,14 +4,16 @@ module RSpec
|
|
4
4
|
module Terraform
|
5
5
|
module Matchers
|
6
6
|
class IncludeOutputChange
|
7
|
-
attr_reader :definition, :value
|
7
|
+
attr_reader :definition, :value, :plan
|
8
8
|
|
9
|
-
def initialize(definition)
|
9
|
+
def initialize(definition = {})
|
10
10
|
@definition = definition
|
11
11
|
@value = nil
|
12
12
|
end
|
13
13
|
|
14
14
|
def matches?(plan)
|
15
|
+
@plan = plan
|
16
|
+
|
15
17
|
!value_matches(plan).empty?
|
16
18
|
end
|
17
19
|
|
@@ -20,6 +22,11 @@ module RSpec
|
|
20
22
|
self
|
21
23
|
end
|
22
24
|
|
25
|
+
def failure_message
|
26
|
+
"\nexpected: #{positive_expected_line}" \
|
27
|
+
"\n got: #{positive_got_line}"
|
28
|
+
end
|
29
|
+
|
23
30
|
private
|
24
31
|
|
25
32
|
def definition_matches(plan)
|
@@ -60,6 +67,55 @@ module RSpec
|
|
60
67
|
|
61
68
|
actual
|
62
69
|
end
|
70
|
+
|
71
|
+
def positive_expected_line
|
72
|
+
maybe_with_definition(
|
73
|
+
positive_plan_line
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
def positive_plan_line
|
78
|
+
'a plan including at least one output change'
|
79
|
+
end
|
80
|
+
|
81
|
+
def maybe_with_definition(expected_line)
|
82
|
+
unless @definition.empty?
|
83
|
+
expected_line =
|
84
|
+
"#{expected_line} matching definition:\n#{definition_lines}"
|
85
|
+
end
|
86
|
+
expected_line
|
87
|
+
end
|
88
|
+
|
89
|
+
def definition_lines
|
90
|
+
indent = ' '
|
91
|
+
definition
|
92
|
+
.collect { |k, v| "#{indent}#{k} = #{v.inspect}" }
|
93
|
+
.join("\n")
|
94
|
+
end
|
95
|
+
|
96
|
+
def positive_got_line
|
97
|
+
if plan.output_changes.empty?
|
98
|
+
'a plan including no output changes.'
|
99
|
+
else
|
100
|
+
with_available_output_changes(
|
101
|
+
'a plan including no matching output changes.'
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def with_available_output_changes(got_line)
|
107
|
+
"#{got_line}\n available output changes are:" \
|
108
|
+
"\n#{available_output_change_lines}"
|
109
|
+
end
|
110
|
+
|
111
|
+
def available_output_change_lines
|
112
|
+
available_lines = plan.output_changes.collect do |oc|
|
113
|
+
name = oc.name
|
114
|
+
actions = oc.change.actions.join(', ')
|
115
|
+
" - #{name} (#{actions})"
|
116
|
+
end
|
117
|
+
available_lines.join("\n")
|
118
|
+
end
|
63
119
|
end
|
64
120
|
end
|
65
121
|
end
|