rspec-terraform 0.1.0.pre.3 → 0.1.0.pre.4

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: 0d1ae3bbe696449adf08d4e720aa1489623646ad6967e7db9c7ba3d8a16d5966
4
- data.tar.gz: 79911852a97c2e56f9333db51cb9ecb018ed8279a44e5e0b15719c970da77e66
3
+ metadata.gz: d7cb3c96cddab5b6da8dfe17777c03db55bcf4aa26f0ace70d0071054fffcd45
4
+ data.tar.gz: 8627531e2f304c235a9187b9a1d93a4e150322c06d53fc0f7838ef814e66908a
5
5
  SHA512:
6
- metadata.gz: 3a5e269614e7e46c619537d1caf3a11d27d41abf82f39ad7263c40753e0ba0f2482ccccb3ea87e08b5d4812c4305ea3fed9fb9509864c7554f2ac195ae882ff2
7
- data.tar.gz: 1be570f2eab2149b815e747e9174d6dd86e4e73c37e1578d0364f6a34a3d78dbd125031d3ca466191234ba9cee401947213f7ef4923a7b7ad84fe44fd5f6f0e2
6
+ metadata.gz: bb8bfc14dd162538c8954c9fddea724e71d787750cc852f9aebf38e9e93602d6ba669a3b2e7d7850d66a655f107b3766537c1238289c7d9faba36a31bcc48199
7
+ data.tar.gz: 2d81dca04084c0662c0470bc4e51fff069feeac4cf9f08c0e2863960b169e1e3065367969bc4b99dd1730e16331616574ed2a4212fee23dc32976e22e8d58810
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.3)
4
+ rspec-terraform (0.1.0.pre.4)
5
5
  rspec (>= 3.0)
6
- ruby-terraform (= 1.7.0.pre.1)
6
+ ruby-terraform (= 1.7.0.pre.3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -37,7 +37,7 @@ GEM
37
37
  lino (3.0.0)
38
38
  hamster (~> 3.0)
39
39
  open4 (~> 1.3)
40
- minitest (5.16.1)
40
+ minitest (5.16.2)
41
41
  octokit (4.25.1)
42
42
  faraday (>= 1, < 3)
43
43
  sawyer (~> 0.9)
@@ -83,7 +83,7 @@ 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.31.1)
86
+ rubocop (1.31.2)
87
87
  json (~> 2.3)
88
88
  parallel (~> 1.10)
89
89
  parser (>= 3.1.0.0)
@@ -97,10 +97,10 @@ GEM
97
97
  parser (>= 3.1.1.0)
98
98
  rubocop-rake (0.6.0)
99
99
  rubocop (~> 1.0)
100
- rubocop-rspec (2.12.0)
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.1)
103
+ ruby-terraform (1.7.0.pre.3)
104
104
  immutable-struct (~> 2.4)
105
105
  lino (~> 3.0)
106
106
  ruby2_keywords (0.0.5)
@@ -1,17 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rspec/matchers/built_in/count_expectation'
4
+
3
5
  module RSpec
4
6
  module Terraform
5
7
  module Matchers
6
8
  class IncludeResourceChange
9
+ include RSpec::Matchers::BuiltIn::CountExpectation
10
+
7
11
  attr_reader :definition
8
12
 
9
13
  def initialize(definition = {})
10
14
  @definition = definition
15
+ @attributes = []
11
16
  end
12
17
 
13
18
  def matches?(plan)
14
- !plan.resource_changes_matching(definition).empty?
19
+ matches = attribute_matches(plan)
20
+
21
+ match_count = matches.count
22
+ if has_expected_count?
23
+ expected_count_matches?(match_count)
24
+ else
25
+ match_count.positive?
26
+ end
27
+ end
28
+
29
+ def with_attribute_value(*args)
30
+ stage, name, value = args.count == 3 ? args : [:after, *args]
31
+ @attributes << { stage: stage, name: name, value: value }
32
+ self
33
+ end
34
+
35
+ private
36
+
37
+ def definition_matches(plan)
38
+ plan.resource_changes_matching(definition)
39
+ end
40
+
41
+ def attribute_matches(plan)
42
+ definition_matches(plan).filter do |resource_change|
43
+ change = resource_change.change
44
+ after = change.after_object
45
+ @attributes.all? do |attribute|
46
+ expected = RubyTerraform::Models::Objects.box(attribute[:value])
47
+ actual = after[attribute[:name]]
48
+ actual == expected
49
+ end
50
+ end
15
51
  end
16
52
  end
17
53
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.3'
5
+ VERSION = '0.1.0.pre.4'
6
6
  end
7
7
  end
@@ -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.1'
41
+ spec.add_dependency 'ruby-terraform', '1.7.0.pre.3'
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.3
4
+ version: 0.1.0.pre.4
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-03 00:00:00.000000000 Z
11
+ date: 2022-07-11 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.1
33
+ version: 1.7.0.pre.3
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.1
40
+ version: 1.7.0.pre.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement