rspec-terraform 0.1.0.pre.43 → 0.1.0.pre.44

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: 8d338f5e02d75bdf58441300199c8902f712adf6582abff8b9e5021230c2d344
4
- data.tar.gz: 16844e10dec62df8e57c1b84216c0f95742586be4fcca7792195d680e526200e
3
+ metadata.gz: 84471e75598a3fc301a717d206fd91ba40583271430805b183cbaf58610a8331
4
+ data.tar.gz: 6178c6b399ff218dffbb21c4f036c64233e3ac84e96ba86660254af7d6f2d4d0
5
5
  SHA512:
6
- metadata.gz: 49b0bc41cde756000e9e74218ab4b2c9ab451e19b8dbdf6f84a3d1d0329c7d6a1bb94ea801bfd15caaa374c512173b62dd137b610c942efafb5401180bc970ea
7
- data.tar.gz: 0631d0581d8f6c6f9a13d8e6edcd9a714b44b6487803c95c0d4a3a5ec5650b129a80fe70054162121b0330e7430cdcf35171727eb406a7da6f964a247f676b43
6
+ metadata.gz: f3b96974345ca144b4314eb2c90237bb238223e706c214fe94b97f4e5462edf969f6b4da8b3cd83a4a81daed33771f18a0e9f415c361ec6f9cb3ebfe97be7b74
7
+ data.tar.gz: 19651b182453d3de16dfca2b5b4fe205df0d2af4bbfdc80dc1aa4d71298cd359a0ce70655720e100dc21f4f1f19b4784f51bdd56b3adfd63c05c3177a825f21d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.43)
4
+ rspec-terraform (0.1.0.pre.44)
5
5
  confidante (>= 0.27)
6
6
  rspec (>= 3.0)
7
7
  ruby-terraform (= 1.7.0.pre.17)
@@ -35,15 +35,24 @@ module RSpec
35
35
  parameters = with_resolved_vars(parameters, &block)
36
36
  parameters = with_mandatory_parameters(parameters)
37
37
 
38
- ensure_required_parameters(parameters)
39
-
40
- clean(parameters)
41
- init(parameters)
42
- apply(parameters)
38
+ execute_if_required(parameters) do
39
+ validate(parameters)
40
+ clean(parameters)
41
+ init(parameters)
42
+ apply(parameters)
43
+ end
43
44
  end
44
45
 
45
46
  private
46
47
 
48
+ def execute_if_required(parameters, &block)
49
+ only_if = parameters[:only_if]
50
+ only_if_args = only_if ? [parameters].slice(0, only_if.arity) : []
51
+ should_execute = only_if ? only_if.call(*only_if_args) : true
52
+
53
+ block.call if should_execute
54
+ end
55
+
47
56
  def with_configuration_provider_parameters(parameters)
48
57
  configuration_provider.resolve(parameters)
49
58
  end
@@ -70,16 +79,6 @@ module RSpec
70
79
  }[execution_mode] || []
71
80
  end
72
81
 
73
- def ensure_required_parameters(parameters)
74
- missing_parameters =
75
- required_parameters(execution_mode)
76
- .filter { |parameter| parameters[parameter].nil? }
77
-
78
- return if missing_parameters.empty?
79
-
80
- raise_missing_parameters(missing_parameters)
81
- end
82
-
83
82
  def raise_missing_parameters(parameters)
84
83
  parameters = parameters.collect { |parameter| "`:#{parameter}`" }
85
84
  if parameters.count == 1
@@ -92,6 +91,16 @@ module RSpec
92
91
  end
93
92
  end
94
93
 
94
+ def validate(parameters)
95
+ missing_parameters =
96
+ required_parameters(execution_mode)
97
+ .filter { |parameter| parameters[parameter].nil? }
98
+
99
+ return if missing_parameters.empty?
100
+
101
+ raise_missing_parameters(missing_parameters)
102
+ end
103
+
95
104
  def clean(parameters)
96
105
  return unless execution_mode == :isolated
97
106
 
@@ -34,15 +34,24 @@ module RSpec
34
34
  parameters = with_configuration_provider_parameters(overrides)
35
35
  parameters = with_resolved_vars(parameters, &block)
36
36
 
37
- ensure_required_parameters(parameters)
38
-
39
- clean(parameters)
40
- init(parameters)
41
- destroy(parameters)
37
+ execute_if_required(parameters) do
38
+ validate(parameters)
39
+ clean(parameters)
40
+ init(parameters)
41
+ destroy(parameters)
42
+ end
42
43
  end
43
44
 
44
45
  private
45
46
 
47
+ def execute_if_required(parameters, &block)
48
+ only_if = parameters[:only_if]
49
+ only_if_args = only_if ? [parameters].slice(0, only_if.arity) : []
50
+ should_execute = only_if ? only_if.call(*only_if_args) : true
51
+
52
+ block.call if should_execute
53
+ end
54
+
46
55
  def with_configuration_provider_parameters(parameters)
47
56
  configuration_provider.resolve(parameters)
48
57
  end
@@ -62,16 +71,6 @@ module RSpec
62
71
  }[execution_mode] || []
63
72
  end
64
73
 
65
- def ensure_required_parameters(parameters)
66
- missing_parameters =
67
- required_parameters(execution_mode)
68
- .filter { |parameter| parameters[parameter].nil? }
69
-
70
- return if missing_parameters.empty?
71
-
72
- raise_missing_parameters(missing_parameters)
73
- end
74
-
75
74
  def raise_missing_parameters(parameters)
76
75
  parameters = parameters.collect { |parameter| "`:#{parameter}`" }
77
76
  if parameters.count == 1
@@ -84,6 +83,16 @@ module RSpec
84
83
  end
85
84
  end
86
85
 
86
+ def validate(parameters)
87
+ missing_parameters =
88
+ required_parameters(execution_mode)
89
+ .filter { |parameter| parameters[parameter].nil? }
90
+
91
+ return if missing_parameters.empty?
92
+
93
+ raise_missing_parameters(missing_parameters)
94
+ end
95
+
87
96
  def clean(parameters)
88
97
  return unless execution_mode == :isolated
89
98
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.43'
5
+ VERSION = '0.1.0.pre.44'
6
6
  end
7
7
  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.43
4
+ version: 0.1.0.pre.44
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-09-08 00:00:00.000000000 Z
11
+ date: 2022-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: confidante