rspec-terraform 0.1.0.pre.8 → 0.1.0.pre.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -1
- data/lib/rspec/terraform/matchers/include_resource_change.rb +39 -5
- 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: 9201cae0c0d9e4823bc90ce3159757ed2171fd2a440d1a1179d37bd2482c9237
|
4
|
+
data.tar.gz: 385dba92ea4a772cdb897db40483451c624506d74cfeb87fd1eb5a2f9e657c79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93b16c7d3c5eeeed2ffee8dd91cf0ff8ea7ff5cc8eef4bb1ab549d2dfa78f1deb2d3ad7708cc5f090f25e1c10613f34c23af447ea190583d60e35d023dcee174
|
7
|
+
data.tar.gz: 07ac2b1aaa4a98e87766f7de30307011811717627ed96879a7c12d3fe13de9f422e64291011ffc972bf0fdb8309cff04f5429fdc3c92de33f004896a66a5d0ee
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -8,6 +8,7 @@ require 'rspec/matchers/built_in/count_expectation'
|
|
8
8
|
module RSpec
|
9
9
|
module Terraform
|
10
10
|
module Matchers
|
11
|
+
# rubocop:disable Metrics/ClassLength
|
11
12
|
class IncludeResourceChange
|
12
13
|
include RSpec::Matchers::BuiltIn::CountExpectation
|
13
14
|
|
@@ -39,7 +40,9 @@ module RSpec
|
|
39
40
|
|
40
41
|
def failure_message
|
41
42
|
"\nexpected: #{positive_expected_line}" \
|
42
|
-
"\n got: #{positive_got_line}"
|
43
|
+
"\n got: #{positive_got_line}" \
|
44
|
+
"\n available resource changes are:" \
|
45
|
+
"\n#{resource_change_lines}"
|
43
46
|
end
|
44
47
|
|
45
48
|
def failure_message_when_negated
|
@@ -83,8 +86,10 @@ module RSpec
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def positive_expected_line
|
86
|
-
cardinality =
|
87
|
-
|
89
|
+
cardinality = cardinality_fragment
|
90
|
+
plurality = expected_count.nil? || expected_count == 1 ? '' : 's'
|
91
|
+
expected_line =
|
92
|
+
"a plan including #{cardinality} resource change#{plurality}"
|
88
93
|
|
89
94
|
unless @definition.empty?
|
90
95
|
expected_line =
|
@@ -96,10 +101,38 @@ module RSpec
|
|
96
101
|
|
97
102
|
def positive_got_line
|
98
103
|
if plan.resource_changes.empty?
|
99
|
-
|
104
|
+
'a plan including no resource changes.'
|
105
|
+
else
|
106
|
+
count = attribute_matches(plan).count
|
107
|
+
amount = count.zero? ? 'no' : cardinality_amount(count)
|
108
|
+
plurality = count == 1 ? '' : 's'
|
109
|
+
"a plan including #{amount} matching resource change#{plurality}."
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def cardinality_fragment
|
114
|
+
qualifier = cardinality_qualifier
|
115
|
+
amount = cardinality_amount(expected_count)
|
116
|
+
"#{qualifier} #{amount}"
|
117
|
+
end
|
118
|
+
|
119
|
+
def cardinality_qualifier
|
120
|
+
case count_expectation_type
|
121
|
+
when :<= then 'at most'
|
122
|
+
when nil, :>= then 'at least'
|
123
|
+
when :== then 'exactly'
|
124
|
+
when :<=> then 'between'
|
100
125
|
end
|
126
|
+
end
|
101
127
|
|
102
|
-
|
128
|
+
def cardinality_amount(count)
|
129
|
+
case count
|
130
|
+
when Range then "#{count.first} and #{count.last}"
|
131
|
+
when nil, 1 then 'one'
|
132
|
+
when 2 then 'two'
|
133
|
+
when 3 then 'three'
|
134
|
+
else count.to_s
|
135
|
+
end
|
103
136
|
end
|
104
137
|
|
105
138
|
def definition_lines
|
@@ -118,6 +151,7 @@ module RSpec
|
|
118
151
|
.join("\n")
|
119
152
|
end
|
120
153
|
end
|
154
|
+
# rubocop:enable Metrics/ClassLength
|
121
155
|
end
|
122
156
|
end
|
123
157
|
end
|