rspec-terraform 0.1.0.pre.7 → 0.1.0.pre.8
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/lib/rspec/terraform/matchers/include_resource_change.rb +48 -49
- data/lib/rspec/terraform/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9616ce6b70683138de564ce5a8e7ff68a892ec5ad3c6db8e8ac5904d07ba889
|
4
|
+
data.tar.gz: cdf25b73c0af2057c9c00130dca4ac9b1a69e282c9134d1389e0ae3862f995d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f27156422ee5fb0742682fec4113fad7429ce5f434c06bd599b5d3fb644988642da7ac582f48950d80060c12ef6215f4859a0f08298da0d7b3d7adbd0eca9b59
|
7
|
+
data.tar.gz: 779b8685fa9858f25bf70ed1455baedebd96f19ec4134f47f8ee3d14fe67dd438e708675c3c6d8f52289798742ca54149f27b3c83476e936fa9e90e0497da02b
|
data/Gemfile.lock
CHANGED
@@ -11,7 +11,7 @@ module RSpec
|
|
11
11
|
class IncludeResourceChange
|
12
12
|
include RSpec::Matchers::BuiltIn::CountExpectation
|
13
13
|
|
14
|
-
attr_reader :definition
|
14
|
+
attr_reader :definition, :plan
|
15
15
|
|
16
16
|
def initialize(definition = {})
|
17
17
|
@definition = definition
|
@@ -19,6 +19,7 @@ module RSpec
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def matches?(plan)
|
22
|
+
@plan = plan
|
22
23
|
matches = attribute_matches(plan)
|
23
24
|
|
24
25
|
match_count = matches.count
|
@@ -36,6 +37,16 @@ module RSpec
|
|
36
37
|
self
|
37
38
|
end
|
38
39
|
|
40
|
+
def failure_message
|
41
|
+
"\nexpected: #{positive_expected_line}" \
|
42
|
+
"\n got: #{positive_got_line}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def failure_message_when_negated
|
46
|
+
"\nexpected: a plan including no resource changes" \
|
47
|
+
"\n got: a plan including at least one resource change"
|
48
|
+
end
|
49
|
+
|
39
50
|
private
|
40
51
|
|
41
52
|
def definition_matches(plan)
|
@@ -70,55 +81,43 @@ module RSpec
|
|
70
81
|
|
71
82
|
actual
|
72
83
|
end
|
84
|
+
|
85
|
+
def positive_expected_line
|
86
|
+
cardinality = 'at least one'
|
87
|
+
expected_line = "a plan including #{cardinality} resource change"
|
88
|
+
|
89
|
+
unless @definition.empty?
|
90
|
+
expected_line =
|
91
|
+
"#{expected_line} matching definition:\n#{definition_lines}"
|
92
|
+
end
|
93
|
+
|
94
|
+
expected_line
|
95
|
+
end
|
96
|
+
|
97
|
+
def positive_got_line
|
98
|
+
if plan.resource_changes.empty?
|
99
|
+
return 'a plan including no resource changes'
|
100
|
+
end
|
101
|
+
|
102
|
+
"a plan with resource changes:\n#{resource_change_lines}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def definition_lines
|
106
|
+
definition
|
107
|
+
.collect { |k, v| " #{k}: #{v}" }
|
108
|
+
.join("\n")
|
109
|
+
end
|
110
|
+
|
111
|
+
def resource_change_lines
|
112
|
+
plan.resource_changes
|
113
|
+
.collect do |rc|
|
114
|
+
address = rc.address
|
115
|
+
actions = rc.change.actions.join(', ')
|
116
|
+
" - #{address} (#{actions})"
|
117
|
+
end
|
118
|
+
.join("\n")
|
119
|
+
end
|
73
120
|
end
|
74
121
|
end
|
75
122
|
end
|
76
123
|
end
|
77
|
-
|
78
|
-
# RSpec::Matchers.define :include_resource_creation do |type|
|
79
|
-
# match do |plan|
|
80
|
-
# resource_changes = plan.resource_changes_with_type(type)
|
81
|
-
# resource_creations = resource_changes.filter(&:create?)
|
82
|
-
#
|
83
|
-
# return false if @count && resource_creations.length != @count
|
84
|
-
# return false if resource_creations.empty?
|
85
|
-
#
|
86
|
-
# pp plan.to_h
|
87
|
-
#
|
88
|
-
# if @arguments
|
89
|
-
# return resource_creations.any? do |resource_creation|
|
90
|
-
# @arguments.all? do |name, value|
|
91
|
-
# resource_creation.change.after[name] == value
|
92
|
-
# end
|
93
|
-
# end
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# return true
|
97
|
-
# end
|
98
|
-
#
|
99
|
-
# chain :count do |count|
|
100
|
-
# @count = count
|
101
|
-
# end
|
102
|
-
#
|
103
|
-
# chain :with_argument_value do |name, value|
|
104
|
-
# @arguments = (@arguments || {}).merge(name => value)
|
105
|
-
# end
|
106
|
-
#
|
107
|
-
# failure_message do |plan|
|
108
|
-
# resource_creations = plan.resource_creations.map do |resource_creation|
|
109
|
-
# "#{resource_creation.type}.#{resource_creation.name}"
|
110
|
-
# end
|
111
|
-
# "\nexpected: a plan with a resource creation for type: #{type}" \
|
112
|
-
# "\n got: a plan with resource creations:" \
|
113
|
-
# "\n - #{resource_creations.join("\n - ")}"
|
114
|
-
# end
|
115
|
-
#
|
116
|
-
# failure_message_when_negated do |plan|
|
117
|
-
# resource_creations = plan.resource_creations.map do |resource_creation|
|
118
|
-
# "#{resource_creation.type}.#{resource_creation.name}"
|
119
|
-
# end
|
120
|
-
# "\nexpected: a plan without a resource creation for type: #{type}" \
|
121
|
-
# "\n got: a plan with resource creations:" \
|
122
|
-
# "\n - #{resource_creations.join("\n - ")}"
|
123
|
-
# end
|
124
|
-
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-terraform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InfraBlocks Maintainers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|