rspec-terraform 0.1.0.pre.17 → 0.1.0.pre.18

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: 1a78765d5eecf1940eb733e53740d9835587ee3f19647222b2b7e3e594b72a23
4
- data.tar.gz: 328c9a749a876711521c9581f0d75a2d9c9ede2821ddbb6012c0acb79869c852
3
+ metadata.gz: 6bea553c61f70c6bd7bf4bdedca8b618a00539e8bfb1de8234e9771c8462c1ca
4
+ data.tar.gz: e3ef056ecdf300bb9c9ce9656090a4ac93703d5346ba36e0f2c3f43885f927da
5
5
  SHA512:
6
- metadata.gz: 61f34656cba5a4fe108338284345256cc9c91cc2939d9a4451ef8a30c08ca978e1ff0a087d2f1b238f88bed7b3a80ef31fa41fc1e610219ec962b65d6fbb1519
7
- data.tar.gz: 1ae1c88f42592e288f7a4e78681479582b1e42baefd25cdb2bbc25d24e5fb586b0a1186ff418628982bc70bf21cd34e6f48d1f6c18f4d76c38a02d1328fe7ab9
6
+ metadata.gz: d68c9235ad0a528f15f1e0801681210561cecf4070b69276fe2a28436e28b3f5748728220382b3e87950a1959a46ce912be09d6b300f94732bf50ebe3a78cfc9
7
+ data.tar.gz: 61b756e071fba7355d294552d042b0d855ac1ca18021f1b06c594b3b3e2fad05d5d53668580880911db3e6c103d5b46579f1a8e28f6d2fc54c08a46014772696
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.17)
4
+ rspec-terraform (0.1.0.pre.18)
5
5
  rspec (>= 3.0)
6
6
  ruby-terraform (= 1.7.0.pre.13)
7
7
 
@@ -4,14 +4,16 @@ module RSpec
4
4
  module Terraform
5
5
  module Matchers
6
6
  class IncludeOutputChange
7
- attr_reader :definition, :value
7
+ attr_reader :definition, :value, :plan
8
8
 
9
- def initialize(definition)
9
+ def initialize(definition = {})
10
10
  @definition = definition
11
11
  @value = nil
12
12
  end
13
13
 
14
14
  def matches?(plan)
15
+ @plan = plan
16
+
15
17
  !value_matches(plan).empty?
16
18
  end
17
19
 
@@ -20,6 +22,11 @@ module RSpec
20
22
  self
21
23
  end
22
24
 
25
+ def failure_message
26
+ "\nexpected: #{positive_expected_line}" \
27
+ "\n got: #{positive_got_line}"
28
+ end
29
+
23
30
  private
24
31
 
25
32
  def definition_matches(plan)
@@ -60,6 +67,55 @@ module RSpec
60
67
 
61
68
  actual
62
69
  end
70
+
71
+ def positive_expected_line
72
+ maybe_with_definition(
73
+ positive_plan_line
74
+ )
75
+ end
76
+
77
+ def positive_plan_line
78
+ 'a plan including at least one output change'
79
+ end
80
+
81
+ def maybe_with_definition(expected_line)
82
+ unless @definition.empty?
83
+ expected_line =
84
+ "#{expected_line} matching definition:\n#{definition_lines}"
85
+ end
86
+ expected_line
87
+ end
88
+
89
+ def definition_lines
90
+ indent = ' '
91
+ definition
92
+ .collect { |k, v| "#{indent}#{k} = #{v.inspect}" }
93
+ .join("\n")
94
+ end
95
+
96
+ def positive_got_line
97
+ if plan.output_changes.empty?
98
+ 'a plan including no output changes.'
99
+ else
100
+ with_available_output_changes(
101
+ 'a plan including no matching output changes.'
102
+ )
103
+ end
104
+ end
105
+
106
+ def with_available_output_changes(got_line)
107
+ "#{got_line}\n available output changes are:" \
108
+ "\n#{available_output_change_lines}"
109
+ end
110
+
111
+ def available_output_change_lines
112
+ available_lines = plan.output_changes.collect do |oc|
113
+ name = oc.name
114
+ actions = oc.change.actions.join(', ')
115
+ " - #{name} (#{actions})"
116
+ end
117
+ available_lines.join("\n")
118
+ end
63
119
  end
64
120
  end
65
121
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.17'
5
+ VERSION = '0.1.0.pre.18'
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.17
4
+ version: 0.1.0.pre.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers