rspec-terraform 0.1.0.pre.11 → 0.1.0.pre.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/rspec/terraform/matchers/include_resource_change.rb +22 -19
- data/lib/rspec/terraform/version.rb +1 -1
- data/rspec-terraform.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f38869b0e2c2de7b280ff09e070c6fa66fecd2ede8dba1e182300306110a20f
|
4
|
+
data.tar.gz: 384a2ec52c9fbf9162ba773a866fec91463c055a0b59bb4fea922fb421d53e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dabc8823fc35214035ea62093bfcc7623ab8d6921b381cb3c74a3f6691d23a35ae4bbb58f65c3d900245a355fd6e69ac3a139f097efb3b81dc8a409c648e0e35
|
7
|
+
data.tar.gz: 97f7670c091ea2051bf812f126fdc32df5f8b10f9e234a3dc95a23b59842b9b0f30af9ffd4164bfaffd57b90e9c6f5b185468648a0da53bb1d3a562eafa7d9c9
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-terraform (0.1.0.pre.
|
4
|
+
rspec-terraform (0.1.0.pre.12)
|
5
5
|
rspec (>= 3.0)
|
6
|
-
ruby-terraform (= 1.7.0.pre.
|
6
|
+
ruby-terraform (= 1.7.0.pre.8)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -83,14 +83,14 @@ GEM
|
|
83
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
84
|
rspec-support (~> 3.11.0)
|
85
85
|
rspec-support (3.11.0)
|
86
|
-
rubocop (1.
|
86
|
+
rubocop (1.32.0)
|
87
87
|
json (~> 2.3)
|
88
88
|
parallel (~> 1.10)
|
89
89
|
parser (>= 3.1.0.0)
|
90
90
|
rainbow (>= 2.2.2, < 4.0)
|
91
91
|
regexp_parser (>= 1.8, < 3.0)
|
92
92
|
rexml (>= 3.2.5, < 4.0)
|
93
|
-
rubocop-ast (>= 1.
|
93
|
+
rubocop-ast (>= 1.19.1, < 2.0)
|
94
94
|
ruby-progressbar (~> 1.7)
|
95
95
|
unicode-display_width (>= 1.4.0, < 3.0)
|
96
96
|
rubocop-ast (1.19.1)
|
@@ -100,7 +100,7 @@ GEM
|
|
100
100
|
rubocop-rspec (2.12.1)
|
101
101
|
rubocop (~> 1.31)
|
102
102
|
ruby-progressbar (1.11.0)
|
103
|
-
ruby-terraform (1.7.0.pre.
|
103
|
+
ruby-terraform (1.7.0.pre.8)
|
104
104
|
immutable-struct (~> 2.4)
|
105
105
|
lino (~> 3.0)
|
106
106
|
ruby2_keywords (0.0.5)
|
@@ -5,6 +5,9 @@ require 'rspec/matchers'
|
|
5
5
|
require 'rspec/matchers/built_in/eq'
|
6
6
|
require 'rspec/matchers/built_in/count_expectation'
|
7
7
|
|
8
|
+
require 'ruby_terraform/models/path'
|
9
|
+
require 'ruby_terraform/models/path_set'
|
10
|
+
|
8
11
|
module RSpec
|
9
12
|
module Terraform
|
10
13
|
module Matchers
|
@@ -34,6 +37,8 @@ module RSpec
|
|
34
37
|
def with_attribute_value(*args)
|
35
38
|
stage, path, value = args.count == 3 ? args : [:after, *args]
|
36
39
|
path = [path] if path.is_a?(Symbol)
|
40
|
+
path = RubyTerraform::Models::Path.new(path)
|
41
|
+
value = maybe_box_value(value)
|
37
42
|
@attributes << { stage: stage, path: path, value: value }
|
38
43
|
self
|
39
44
|
end
|
@@ -66,18 +71,24 @@ module RSpec
|
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
74
|
+
def maybe_box_value(value)
|
75
|
+
if value.respond_to?(:matches?)
|
76
|
+
value
|
77
|
+
else
|
78
|
+
RubyTerraform::Models::Objects.box(value)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
def attribute_matcher(attribute)
|
70
83
|
expected = attribute[:value]
|
71
84
|
return expected if expected.respond_to?(:matches?)
|
72
85
|
|
73
|
-
RSpec::Matchers::BuiltIn::Eq.new(
|
74
|
-
RubyTerraform::Models::Objects.box(expected)
|
75
|
-
)
|
86
|
+
RSpec::Matchers::BuiltIn::Eq.new(expected)
|
76
87
|
end
|
77
88
|
|
78
89
|
def attribute_value(object, attribute)
|
79
90
|
expected = attribute[:value]
|
80
|
-
actual =
|
91
|
+
actual = attribute[:path].read(object)
|
81
92
|
return actual&.unbox if expected.respond_to?(:matches?)
|
82
93
|
|
83
94
|
actual
|
@@ -172,28 +183,24 @@ module RSpec
|
|
172
183
|
end
|
173
184
|
|
174
185
|
def expected_attribute_lines
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
186
|
+
paths = attributes.collect { |attribute| attribute[:path] }
|
187
|
+
path_set = RubyTerraform::Models::PathSet.new(paths)
|
188
|
+
values = attributes.collect { |attribute| attribute[:value] }
|
189
|
+
object = RubyTerraform::Models::Objects.object(path_set, values)
|
190
|
+
object.render(level: 6, bare: true)
|
180
191
|
end
|
181
192
|
|
182
|
-
# rubocop:disable Metrics/MethodLength
|
183
193
|
def relevant_resource_change_lines
|
184
194
|
relevant_lines = definition_matches(plan).collect do |rc|
|
185
195
|
address = rc.address
|
186
196
|
actions = rc.change.actions.join(', ')
|
187
197
|
attributes = rc.change.after_object
|
188
|
-
attribute_lines = attributes.
|
189
|
-
|
190
|
-
end
|
191
|
-
attribute_lines = attribute_lines.join("\n")
|
198
|
+
attribute_lines = attributes.render(level: 8, bare: true)
|
199
|
+
|
192
200
|
" - #{address} (#{actions})\n#{attribute_lines}"
|
193
201
|
end
|
194
202
|
relevant_lines.join("\n")
|
195
203
|
end
|
196
|
-
# rubocop:enable Metrics/MethodLength
|
197
204
|
|
198
205
|
def available_resource_change_lines
|
199
206
|
available_lines = plan.resource_changes.collect do |rc|
|
@@ -203,10 +210,6 @@ module RSpec
|
|
203
210
|
end
|
204
211
|
available_lines.join("\n")
|
205
212
|
end
|
206
|
-
|
207
|
-
def render(path)
|
208
|
-
path.collect { |elem| elem.to_s }.join(',')
|
209
|
-
end
|
210
213
|
end
|
211
214
|
|
212
215
|
# rubocop:enable Metrics/ClassLength
|
data/rspec-terraform.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.required_ruby_version = '>= 2.7'
|
39
39
|
|
40
40
|
spec.add_dependency 'rspec', '>= 3.0'
|
41
|
-
spec.add_dependency 'ruby-terraform', '1.7.0.pre.
|
41
|
+
spec.add_dependency 'ruby-terraform', '1.7.0.pre.8'
|
42
42
|
|
43
43
|
spec.add_development_dependency 'bundler'
|
44
44
|
spec.add_development_dependency 'faker'
|
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.12
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.7.0.pre.
|
33
|
+
version: 1.7.0.pre.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.7.0.pre.
|
40
|
+
version: 1.7.0.pre.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|