rspec-terraform 0.1.0.pre.8 → 0.1.0.pre.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9616ce6b70683138de564ce5a8e7ff68a892ec5ad3c6db8e8ac5904d07ba889
4
- data.tar.gz: cdf25b73c0af2057c9c00130dca4ac9b1a69e282c9134d1389e0ae3862f995d3
3
+ metadata.gz: 9201cae0c0d9e4823bc90ce3159757ed2171fd2a440d1a1179d37bd2482c9237
4
+ data.tar.gz: 385dba92ea4a772cdb897db40483451c624506d74cfeb87fd1eb5a2f9e657c79
5
5
  SHA512:
6
- metadata.gz: f27156422ee5fb0742682fec4113fad7429ce5f434c06bd599b5d3fb644988642da7ac582f48950d80060c12ef6215f4859a0f08298da0d7b3d7adbd0eca9b59
7
- data.tar.gz: 779b8685fa9858f25bf70ed1455baedebd96f19ec4134f47f8ee3d14fe67dd438e708675c3c6d8f52289798742ca54149f27b3c83476e936fa9e90e0497da02b
6
+ metadata.gz: 93b16c7d3c5eeeed2ffee8dd91cf0ff8ea7ff5cc8eef4bb1ab549d2dfa78f1deb2d3ad7708cc5f090f25e1c10613f34c23af447ea190583d60e35d023dcee174
7
+ data.tar.gz: 07ac2b1aaa4a98e87766f7de30307011811717627ed96879a7c12d3fe13de9f422e64291011ffc972bf0fdb8309cff04f5429fdc3c92de33f004896a66a5d0ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.8)
4
+ rspec-terraform (0.1.0.pre.9)
5
5
  rspec (>= 3.0)
6
6
  ruby-terraform (= 1.7.0.pre.5)
7
7
 
data/Rakefile CHANGED
@@ -66,7 +66,7 @@ namespace :library do
66
66
  task check: [:rubocop]
67
67
 
68
68
  desc 'Attempt to automatically fix issues with the library'
69
- task fix: [:'rubocop:autocorrect']
69
+ task fix: [:'rubocop:autocorrect_all']
70
70
  end
71
71
 
72
72
  namespace :test do
@@ -8,6 +8,7 @@ require 'rspec/matchers/built_in/count_expectation'
8
8
  module RSpec
9
9
  module Terraform
10
10
  module Matchers
11
+ # rubocop:disable Metrics/ClassLength
11
12
  class IncludeResourceChange
12
13
  include RSpec::Matchers::BuiltIn::CountExpectation
13
14
 
@@ -39,7 +40,9 @@ module RSpec
39
40
 
40
41
  def failure_message
41
42
  "\nexpected: #{positive_expected_line}" \
42
- "\n got: #{positive_got_line}"
43
+ "\n got: #{positive_got_line}" \
44
+ "\n available resource changes are:" \
45
+ "\n#{resource_change_lines}"
43
46
  end
44
47
 
45
48
  def failure_message_when_negated
@@ -83,8 +86,10 @@ module RSpec
83
86
  end
84
87
 
85
88
  def positive_expected_line
86
- cardinality = 'at least one'
87
- expected_line = "a plan including #{cardinality} resource change"
89
+ cardinality = cardinality_fragment
90
+ plurality = expected_count.nil? || expected_count == 1 ? '' : 's'
91
+ expected_line =
92
+ "a plan including #{cardinality} resource change#{plurality}"
88
93
 
89
94
  unless @definition.empty?
90
95
  expected_line =
@@ -96,10 +101,38 @@ module RSpec
96
101
 
97
102
  def positive_got_line
98
103
  if plan.resource_changes.empty?
99
- return 'a plan including no resource changes'
104
+ 'a plan including no resource changes.'
105
+ else
106
+ count = attribute_matches(plan).count
107
+ amount = count.zero? ? 'no' : cardinality_amount(count)
108
+ plurality = count == 1 ? '' : 's'
109
+ "a plan including #{amount} matching resource change#{plurality}."
110
+ end
111
+ end
112
+
113
+ def cardinality_fragment
114
+ qualifier = cardinality_qualifier
115
+ amount = cardinality_amount(expected_count)
116
+ "#{qualifier} #{amount}"
117
+ end
118
+
119
+ def cardinality_qualifier
120
+ case count_expectation_type
121
+ when :<= then 'at most'
122
+ when nil, :>= then 'at least'
123
+ when :== then 'exactly'
124
+ when :<=> then 'between'
100
125
  end
126
+ end
101
127
 
102
- "a plan with resource changes:\n#{resource_change_lines}"
128
+ def cardinality_amount(count)
129
+ case count
130
+ when Range then "#{count.first} and #{count.last}"
131
+ when nil, 1 then 'one'
132
+ when 2 then 'two'
133
+ when 3 then 'three'
134
+ else count.to_s
135
+ end
103
136
  end
104
137
 
105
138
  def definition_lines
@@ -118,6 +151,7 @@ module RSpec
118
151
  .join("\n")
119
152
  end
120
153
  end
154
+ # rubocop:enable Metrics/ClassLength
121
155
  end
122
156
  end
123
157
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.8'
5
+ VERSION = '0.1.0.pre.9'
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.8
4
+ version: 0.1.0.pre.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers