rspec-terraform 0.1.0.pre.48 → 0.1.0.pre.49

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: c565d7154d7321b3b6b9452592201b5230bbba63e30a3603e233f9ebd8f5bc9d
4
- data.tar.gz: d9a59fe476ba65bd885da0386e3696e9e41daaf71b98d48f4c89a6dbcc7d56ba
3
+ metadata.gz: 71e9d6c1dcc91011ceaaf7e50cb2f449453ed10157afa51675e644404df114cb
4
+ data.tar.gz: c7efffc268030aedb282fb8e72dfb2d7d1ee9ae97c8fe0896f08e3817aeb8a42
5
5
  SHA512:
6
- metadata.gz: 05d52e392f0a08c5d4e1cd1eefccba1d11782f628c88426815e1ae5665e1aaf024f8119d2be4de264487670471bdb52bc8636e52be9c61249491180b433ad8ca
7
- data.tar.gz: 7d5f89bd7ca96606e89104b4541f9ccde0b89619b0bbcedad2c95b63e5b82ac87ae31a05eaf2dafaf758131970d34be8576123a0f791bd3aff8921b0e13d5338
6
+ metadata.gz: a57bb3067903397d0378278b20a4e1f91ff1e5fde1576a8e156221279d33d64a316d3704b6f5cbad2317e000e80a12ec4c152f7b7fcda731f1956516c7363f62
7
+ data.tar.gz: '094cc08b00bf0209439809d707636a1a4bcf112865bc6f6ce9a90b0d558719e11fcb18ad318bf4f81a08fed2938ce71057463cdf44a4f5abfc645c6ebbd7bd9a'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.48)
4
+ rspec-terraform (0.1.0.pre.49)
5
5
  confidante (>= 0.27)
6
6
  rspec (>= 3.0)
7
7
  ruby-terraform (= 1.7.0.pre.17)
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # RSpec::Terraform
2
2
 
3
- RSpec support for testing Terraform configurations.
3
+ An RSpec extension for verifying Terraform configurations, with support for:
4
+
5
+ * unit testing;
6
+ * integration testing;
7
+ * end-to-end testing; and
8
+ * change auditing.
4
9
 
5
10
  ## Installation
6
11
 
@@ -20,19 +25,167 @@ Or install it yourself as:
20
25
 
21
26
  ## Usage
22
27
 
23
- TODO: Write docs.
28
+ To use RSpec::Terraform, require it in your `spec_helper.rb` file:
29
+
30
+ ```ruby
31
+ require 'rspec/terraform'
32
+ ```
33
+
34
+ When required, RSpec::Terraform automatically configures itself against
35
+ RSpec by:
36
+
37
+ * adding helper methods to interact with Terraform;
38
+ * adding matchers to verify Terraform plans; and
39
+ * adding settings to control RSpec::Terraform's behaviour.
40
+
41
+ The sections below provide further details on each of these additions.
42
+
43
+ ### Helper methods
44
+
45
+ RSpec::Terraform adds helper methods to the RSpec DSL for planning, applying,
46
+ and destroying Terraform configurations, as well as accessing variables to and
47
+ outputs from Terraform configurations.
48
+
49
+ Each helper method takes a hash of parameters used to identify the configuration
50
+ against which to act and to provide as options to the Terraform command being
51
+ executed. Additionally, RSpec::Terraform includes a flexible approach to
52
+ resolving these parameters allowing them to be sourced from a variety of
53
+ locations. See the [Configuration Providers](#configuration-providers) section
54
+ for more details.
55
+
56
+ When executing helper methods, RSpec::Terraform provides two execution modes,
57
+ `:in_place` and `:isolated`. By default, RSpec::Terraform works against a
58
+ Terraform configuration _in place_, i.e., it executes commands against the
59
+ Terraform configuration directly, in the location specified. RSpec::Terraform
60
+ can also operate in an _isolated_ manner, wherein it initialises the
61
+ configuration into an isolated directory before executing commands. See the
62
+ [Execution Mode](#execution-mode) section for more details.
63
+
64
+ #### `plan`
65
+
66
+ The `plan` helper produces a Terraform plan for a configuration, reads it
67
+ into a Ruby representation and returns it.
68
+
69
+ `plan` requires a `:configuration_directory` parameter, representing the path
70
+ to the configuration to plan and is typically invoked in a `before(:context)`
71
+ hook, with the resulting plan stored for use in expectations:
72
+
73
+ ```ruby
74
+ before(:context) do
75
+ @plan = plan(
76
+ configuration_directory: 'path/to/configuration/directory'
77
+ )
78
+ end
79
+ ```
80
+
81
+ If the configuration has input variables, a `:vars` parameter can be provided
82
+ as a hash:
83
+
84
+ ```ruby
85
+ before(:context) do
86
+ @plan = plan(
87
+ configuration_directory: 'path/to/configuration/directory',
88
+ vars: {
89
+ region: 'uk',
90
+ zones: ['uk-a', 'uk-b'],
91
+ tags: {
92
+ name: 'important-thing',
93
+ role: 'persistence'
94
+ }
95
+ }
96
+ )
97
+ end
98
+ ```
99
+
100
+ or within a block:
101
+
102
+ ```ruby
103
+ before(:context) do
104
+ @plan = plan(
105
+ configuration_directory: 'path/to/configuration/directory'
106
+ ) do |vars|
107
+ vars.region = 'uk'
108
+ vars.zones = ['uk-a', 'uk-b']
109
+ vars.tags = {
110
+ name: 'important-thing',
111
+ role: 'persistence'
112
+ }
113
+ end
114
+ end
115
+ ```
116
+
117
+ `plan` accepts an optional `:state_file` parameter with the path to where the
118
+ current state file for the configuration is located, useful when checking the
119
+ incremental change that applying the configuration would have after a previous
120
+ apply.
121
+
122
+ Internally, `plan`:
123
+ * calls `terraform init` to initialise the configuration directory;
124
+ * calls `terraform plan` to produce a plan file;
125
+ * calls `terraform show` to read the contents of the plan file into a Ruby
126
+ representation; and
127
+ * deletes the plan file.
128
+
129
+ Any additional parameters passed to `plan` are passed on to the underlying
130
+ Terraform invocations.
131
+
132
+ #### `apply`
133
+
134
+ #### `destroy`
135
+
136
+ #### `output`
137
+
138
+ #### `var`
139
+
140
+ ### Plan Matchers
141
+
142
+ ### Settings
143
+
144
+ #### Binary Location
145
+
146
+ #### Logging and Standard Streams
147
+
148
+ #### Execution Mode
149
+
150
+ The benefit of isolated execution is that nothing is carried over between test
151
+ runs and providers and modules are fetched into a clean configuration directory
152
+ every time. The downside is additional test run time.
153
+
154
+ #### Configuration Providers
155
+
156
+ ### Frequently Asked Questions
24
157
 
25
158
  ## Development
26
159
 
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
28
- `rake spec` to run the tests. You can also run `bin/console` for an interactive
29
- prompt that will allow you to experiment.
160
+ To install dependencies and run the build, run the pre-commit build:
161
+
162
+ ```shell
163
+ ./go
164
+ ```
165
+
166
+ This runs all unit tests and other checks including coverage and code linting /
167
+ formatting.
168
+
169
+ To run only the unit tests, including coverage:
170
+
171
+ ```shell
172
+ ./go test:unit
173
+ ```
174
+
175
+ To attempt to fix any code linting / formatting issues:
176
+
177
+ ```shell
178
+ ./go library:fix
179
+ ```
180
+
181
+ To check for code linting / formatting issues without fixing:
182
+
183
+ ```shell
184
+ ./go library:check
185
+ ```
30
186
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To
32
- release a new version, update the version number in `version.rb`, and then run
33
- `bundle exec rake release`, which will create a git tag for the version, push
34
- git commits and tags, and push the `.gem` file to
35
- [rubygems.org](https://rubygems.org).
187
+ You can also run `bin/console` for an interactive prompt that will allow you to
188
+ experiment.
36
189
 
37
190
  ### Managing CircleCI keys
38
191
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.48'
5
+ VERSION = '0.1.0.pre.49'
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.48
4
+ version: 0.1.0.pre.49
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-30 00:00:00.000000000 Z
11
+ date: 2022-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: confidante