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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6ac4e2b2d77dd35725d9b20272c00e2dc5169b0a7a95b6855b8922490f10c3c
4
- data.tar.gz: aef35909c6f6fd8ac38e08361d9938dca36889a48546edaf65ffb4df1c9787a5
3
+ metadata.gz: 1a78765d5eecf1940eb733e53740d9835587ee3f19647222b2b7e3e594b72a23
4
+ data.tar.gz: 328c9a749a876711521c9581f0d75a2d9c9ede2821ddbb6012c0acb79869c852
5
5
  SHA512:
6
- metadata.gz: '038f3ef462faa363b6502df52393220c9905bffaf8169a6766e93fc7842a8ff3c3c0517f038e424c098670eeea22bf72ca3d291ba26b7066942d1d061d440c35'
7
- data.tar.gz: d0eaae468c9796b7e76e4607229901ffbc538be736da7934c20305e118d522874df8f3bb65d7a1e7123adf297f040d1b37265dfa5098a8c1c753e1cbe93e9e9b
6
+ metadata.gz: 61f34656cba5a4fe108338284345256cc9c91cc2939d9a4451ef8a30c08ca978e1ff0a087d2f1b238f88bed7b3a80ef31fa41fc1e610219ec962b65d6fbb1519
7
+ data.tar.gz: 1ae1c88f42592e288f7a4e78681479582b1e42baefd25cdb2bbc25d24e5fb586b0a1186ff418628982bc70bf21cd34e6f48d1f6c18f4d76c38a02d1328fe7ab9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.16)
4
+ rspec-terraform (0.1.0.pre.17)
5
5
  rspec (>= 3.0)
6
6
  ruby-terraform (= 1.7.0.pre.13)
7
7
 
@@ -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
- !definition_matches(plan).empty?
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.16'
5
+ VERSION = '0.1.0.pre.17'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.16
4
+ version: 0.1.0.pre.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers