rspec-terraform 0.1.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +75 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +145 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +146 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/rspec/terraform/matchers/include_resource_change.rb +67 -0
- data/lib/rspec/terraform/matchers.rb +33 -0
- data/lib/rspec/terraform/version.rb +7 -0
- data/lib/rspec/terraform.rb +11 -0
- data/rspec-terraform.gemspec +57 -0
- metadata +254 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d1ae3bbe696449adf08d4e720aa1489623646ad6967e7db9c7ba3d8a16d5966
|
4
|
+
data.tar.gz: 79911852a97c2e56f9333db51cb9ecb018ed8279a44e5e0b15719c970da77e66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a5e269614e7e46c619537d1caf3a11d27d41abf82f39ad7263c40753e0ba0f2482ccccb3ea87e08b5d4812c4305ea3fed9fb9509864c7554f2ac195ae882ff2
|
7
|
+
data.tar.gz: 1be570f2eab2149b815e747e9174d6dd86e4e73c37e1578d0364f6a34a3d78dbd125031d3ca466191234ba9cee401947213f7ef4923a7b7ad84fe44fd5f6f0e2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of
|
9
|
+
experience, nationality, personal appearance, race, religion, or sexual identity
|
10
|
+
and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at maintainers@infrablocks.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
62
|
+
incident. Further details of specific enforcement policies may be posted
|
63
|
+
separately.
|
64
|
+
|
65
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
66
|
+
faith may face temporary or permanent repercussions as determined by other
|
67
|
+
members of the project's leadership.
|
68
|
+
|
69
|
+
## Attribution
|
70
|
+
|
71
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
72
|
+
version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
73
|
+
|
74
|
+
[homepage]: http://contributor-covenant.org
|
75
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-terraform (0.1.0.pre.3)
|
5
|
+
rspec (>= 3.0)
|
6
|
+
ruby-terraform (= 1.7.0.pre.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (7.0.3)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
addressable (2.8.0)
|
17
|
+
public_suffix (>= 2.0.2, < 5.0)
|
18
|
+
ast (2.4.2)
|
19
|
+
colored2 (3.1.2)
|
20
|
+
concurrent-ruby (1.1.10)
|
21
|
+
diff-lcs (1.5.0)
|
22
|
+
docile (1.4.0)
|
23
|
+
excon (0.92.3)
|
24
|
+
faker (2.21.0)
|
25
|
+
i18n (>= 1.8.11, < 2)
|
26
|
+
faraday (2.3.0)
|
27
|
+
faraday-net_http (~> 2.0)
|
28
|
+
ruby2_keywords (>= 0.0.4)
|
29
|
+
faraday-net_http (2.0.3)
|
30
|
+
gem-release (2.2.2)
|
31
|
+
hamster (3.0.0)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
i18n (1.10.0)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
immutable-struct (2.4.1)
|
36
|
+
json (2.6.2)
|
37
|
+
lino (3.0.0)
|
38
|
+
hamster (~> 3.0)
|
39
|
+
open4 (~> 1.3)
|
40
|
+
minitest (5.16.1)
|
41
|
+
octokit (4.25.1)
|
42
|
+
faraday (>= 1, < 3)
|
43
|
+
sawyer (~> 0.9)
|
44
|
+
open4 (1.3.4)
|
45
|
+
parallel (1.22.1)
|
46
|
+
parser (3.1.2.0)
|
47
|
+
ast (~> 2.4.1)
|
48
|
+
public_suffix (4.0.7)
|
49
|
+
rainbow (3.1.1)
|
50
|
+
rake (13.0.6)
|
51
|
+
rake_circle_ci (0.9.0)
|
52
|
+
colored2 (~> 3.1)
|
53
|
+
excon (~> 0.72)
|
54
|
+
rake_factory (~> 0.23)
|
55
|
+
sshkey (~> 2.0)
|
56
|
+
rake_factory (0.29.0)
|
57
|
+
activesupport (>= 4)
|
58
|
+
rake (~> 13.0)
|
59
|
+
rake_github (0.9.0)
|
60
|
+
colored2 (~> 3.1)
|
61
|
+
octokit (~> 4.16)
|
62
|
+
rake_factory (~> 0.23)
|
63
|
+
sshkey (~> 2.0)
|
64
|
+
rake_gpg (0.16.0)
|
65
|
+
rake_factory (>= 0.23, < 1)
|
66
|
+
ruby_gpg2 (>= 0.6, < 1)
|
67
|
+
rake_ssh (0.6.0)
|
68
|
+
colored2 (~> 3.1)
|
69
|
+
rake_factory (~> 0.23)
|
70
|
+
sshkey (~> 2.0)
|
71
|
+
regexp_parser (2.5.0)
|
72
|
+
rexml (3.2.5)
|
73
|
+
rspec (3.11.0)
|
74
|
+
rspec-core (~> 3.11.0)
|
75
|
+
rspec-expectations (~> 3.11.0)
|
76
|
+
rspec-mocks (~> 3.11.0)
|
77
|
+
rspec-core (3.11.0)
|
78
|
+
rspec-support (~> 3.11.0)
|
79
|
+
rspec-expectations (3.11.0)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.11.0)
|
82
|
+
rspec-mocks (3.11.1)
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
+
rspec-support (~> 3.11.0)
|
85
|
+
rspec-support (3.11.0)
|
86
|
+
rubocop (1.31.1)
|
87
|
+
json (~> 2.3)
|
88
|
+
parallel (~> 1.10)
|
89
|
+
parser (>= 3.1.0.0)
|
90
|
+
rainbow (>= 2.2.2, < 4.0)
|
91
|
+
regexp_parser (>= 1.8, < 3.0)
|
92
|
+
rexml (>= 3.2.5, < 4.0)
|
93
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
94
|
+
ruby-progressbar (~> 1.7)
|
95
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
+
rubocop-ast (1.18.0)
|
97
|
+
parser (>= 3.1.1.0)
|
98
|
+
rubocop-rake (0.6.0)
|
99
|
+
rubocop (~> 1.0)
|
100
|
+
rubocop-rspec (2.12.0)
|
101
|
+
rubocop (~> 1.31)
|
102
|
+
ruby-progressbar (1.11.0)
|
103
|
+
ruby-terraform (1.7.0.pre.1)
|
104
|
+
immutable-struct (~> 2.4)
|
105
|
+
lino (~> 3.0)
|
106
|
+
ruby2_keywords (0.0.5)
|
107
|
+
ruby_gpg2 (0.8.0)
|
108
|
+
lino (>= 1.5)
|
109
|
+
sawyer (0.9.2)
|
110
|
+
addressable (>= 2.3.5)
|
111
|
+
faraday (>= 0.17.3, < 3)
|
112
|
+
simplecov (0.21.2)
|
113
|
+
docile (~> 1.1)
|
114
|
+
simplecov-html (~> 0.11)
|
115
|
+
simplecov_json_formatter (~> 0.1)
|
116
|
+
simplecov-html (0.12.3)
|
117
|
+
simplecov_json_formatter (0.1.4)
|
118
|
+
sshkey (2.0.0)
|
119
|
+
tzinfo (2.0.4)
|
120
|
+
concurrent-ruby (~> 1.0)
|
121
|
+
unicode-display_width (2.2.0)
|
122
|
+
|
123
|
+
PLATFORMS
|
124
|
+
arm64-darwin-21
|
125
|
+
ruby
|
126
|
+
x86_64-darwin-19
|
127
|
+
x86_64-linux
|
128
|
+
|
129
|
+
DEPENDENCIES
|
130
|
+
bundler
|
131
|
+
faker
|
132
|
+
gem-release
|
133
|
+
rake
|
134
|
+
rake_circle_ci
|
135
|
+
rake_github
|
136
|
+
rake_gpg
|
137
|
+
rake_ssh
|
138
|
+
rspec-terraform!
|
139
|
+
rubocop
|
140
|
+
rubocop-rake
|
141
|
+
rubocop-rspec
|
142
|
+
simplecov
|
143
|
+
|
144
|
+
BUNDLED WITH
|
145
|
+
2.3.17
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 InfraBlocks Maintainers
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# RSpec::Terraform
|
2
|
+
|
3
|
+
RSpec support for testing Terraform configurations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rspec-terraform'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rspec-terraform
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write docs.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
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.
|
30
|
+
|
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).
|
36
|
+
|
37
|
+
### Managing CircleCI keys
|
38
|
+
|
39
|
+
To encrypt a GPG key for use by CircleCI:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
openssl aes-256-cbc \
|
43
|
+
-e \
|
44
|
+
-md sha1 \
|
45
|
+
-in ./config/secrets/ci/gpg.private \
|
46
|
+
-out ./.circleci/gpg.private.enc \
|
47
|
+
-k "<passphrase>"
|
48
|
+
```
|
49
|
+
|
50
|
+
To check decryption is working correctly:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
openssl aes-256-cbc \
|
54
|
+
-d \
|
55
|
+
-md sha1 \
|
56
|
+
-in ./.circleci/gpg.private.enc \
|
57
|
+
-k "<passphrase>"
|
58
|
+
```
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at
|
63
|
+
https://github.com/infrablocks/rspec-terraform. This project is intended to be a
|
64
|
+
safe, welcoming space for collaboration, and contributors are expected to
|
65
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
|
66
|
+
conduct.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the
|
71
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'rake_circle_ci'
|
5
|
+
require 'rake_github'
|
6
|
+
require 'rake_ssh'
|
7
|
+
require 'rake_gpg'
|
8
|
+
require 'securerandom'
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
|
12
|
+
task default: %i[
|
13
|
+
library:fix
|
14
|
+
test:unit
|
15
|
+
]
|
16
|
+
|
17
|
+
namespace :encryption do
|
18
|
+
namespace :directory do
|
19
|
+
desc 'Ensure CI secrets directory exists.'
|
20
|
+
task :ensure do
|
21
|
+
FileUtils.mkdir_p('config/secrets/ci')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :passphrase do
|
26
|
+
desc 'Generate encryption passphrase used by CI.'
|
27
|
+
task generate: ['directory:ensure'] do
|
28
|
+
File.write('config/secrets/ci/encryption.passphrase',
|
29
|
+
SecureRandom.base64(36))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :keys do
|
35
|
+
namespace :deploy do
|
36
|
+
RakeSSH.define_key_tasks(
|
37
|
+
path: 'config/secrets/ci/',
|
38
|
+
comment: 'maintainers@infrablocks.io'
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
namespace :gpg do
|
43
|
+
RakeGPG.define_generate_key_task(
|
44
|
+
output_directory: 'config/secrets/ci',
|
45
|
+
name_prefix: 'gpg',
|
46
|
+
owner_name: 'InfraBlocks Maintainers',
|
47
|
+
owner_email: 'maintainers@infrablocks.io',
|
48
|
+
owner_comment: 'rspec-terraform CI Key'
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :secrets do
|
54
|
+
desc 'Regenerate all generatable secrets.'
|
55
|
+
task regenerate: %w[
|
56
|
+
encryption:passphrase:generate
|
57
|
+
keys:deploy:generate
|
58
|
+
keys:gpg:generate
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
RuboCop::RakeTask.new
|
63
|
+
|
64
|
+
namespace :library do
|
65
|
+
desc 'Run all checks of the library'
|
66
|
+
task check: [:rubocop]
|
67
|
+
|
68
|
+
desc 'Attempt to automatically fix issues with the library'
|
69
|
+
task fix: [:'rubocop:autocorrect']
|
70
|
+
end
|
71
|
+
|
72
|
+
namespace :test do
|
73
|
+
RSpec::Core::RakeTask.new(:unit)
|
74
|
+
end
|
75
|
+
|
76
|
+
RakeCircleCI.define_project_tasks(
|
77
|
+
namespace: :circle_ci,
|
78
|
+
project_slug: 'github/infrablocks/rspec-terraform'
|
79
|
+
) do |t|
|
80
|
+
circle_ci_config =
|
81
|
+
YAML.load_file('config/secrets/circle_ci/config.yaml')
|
82
|
+
|
83
|
+
t.api_token = circle_ci_config['circle_ci_api_token']
|
84
|
+
t.environment_variables = {
|
85
|
+
ENCRYPTION_PASSPHRASE:
|
86
|
+
File.read('config/secrets/ci/encryption.passphrase')
|
87
|
+
.chomp
|
88
|
+
}
|
89
|
+
t.checkout_keys = []
|
90
|
+
t.ssh_keys = [
|
91
|
+
{
|
92
|
+
hostname: 'github.com',
|
93
|
+
private_key: File.read('config/secrets/ci/ssh.private')
|
94
|
+
}
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
RakeGithub.define_repository_tasks(
|
99
|
+
namespace: :github,
|
100
|
+
repository: 'infrablocks/rspec-terraform'
|
101
|
+
) do |t, args|
|
102
|
+
github_config =
|
103
|
+
YAML.load_file('config/secrets/github/config.yaml')
|
104
|
+
|
105
|
+
t.access_token = github_config['github_personal_access_token']
|
106
|
+
t.deploy_keys = [
|
107
|
+
{
|
108
|
+
title: 'CircleCI',
|
109
|
+
public_key: File.read('config/secrets/ci/ssh.public')
|
110
|
+
}
|
111
|
+
]
|
112
|
+
t.branch_name = args.branch_name
|
113
|
+
t.commit_message = args.commit_message
|
114
|
+
end
|
115
|
+
|
116
|
+
namespace :pipeline do
|
117
|
+
desc 'Prepare CircleCI Pipeline'
|
118
|
+
task prepare: %i[
|
119
|
+
circle_ci:project:follow
|
120
|
+
circle_ci:env_vars:ensure
|
121
|
+
circle_ci:checkout_keys:ensure
|
122
|
+
circle_ci:ssh_keys:ensure
|
123
|
+
github:deploy_keys:ensure
|
124
|
+
]
|
125
|
+
end
|
126
|
+
|
127
|
+
namespace :version do
|
128
|
+
desc 'Bump version for specified type (pre, major, minor, patch)'
|
129
|
+
task :bump, [:type] do |_, args|
|
130
|
+
bump_version_for(args.type)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc 'Release gem'
|
135
|
+
task :release do
|
136
|
+
sh 'gem release --tag --push'
|
137
|
+
end
|
138
|
+
|
139
|
+
def bump_version_for(version_type)
|
140
|
+
version_file = 'lib/rspec/terraform/version.rb'
|
141
|
+
|
142
|
+
sh "gem bump --file #{version_file} --version #{version_type} " \
|
143
|
+
'&& bundle install ' \
|
144
|
+
'&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
|
145
|
+
'&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
|
146
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rspec/terraform'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module Terraform
|
5
|
+
module Matchers
|
6
|
+
class IncludeResourceChange
|
7
|
+
attr_reader :definition
|
8
|
+
|
9
|
+
def initialize(definition = {})
|
10
|
+
@definition = definition
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(plan)
|
14
|
+
!plan.resource_changes_matching(definition).empty?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# RSpec::Matchers.define :include_resource_creation do |type|
|
22
|
+
# match do |plan|
|
23
|
+
# resource_changes = plan.resource_changes_with_type(type)
|
24
|
+
# resource_creations = resource_changes.filter(&:create?)
|
25
|
+
#
|
26
|
+
# return false if @count && resource_creations.length != @count
|
27
|
+
# return false if resource_creations.empty?
|
28
|
+
#
|
29
|
+
# pp plan.to_h
|
30
|
+
#
|
31
|
+
# if @arguments
|
32
|
+
# return resource_creations.any? do |resource_creation|
|
33
|
+
# @arguments.all? do |name, value|
|
34
|
+
# resource_creation.change.after[name] == value
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# return true
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# chain :count do |count|
|
43
|
+
# @count = count
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# chain :with_argument_value do |name, value|
|
47
|
+
# @arguments = (@arguments || {}).merge(name => value)
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# failure_message do |plan|
|
51
|
+
# resource_creations = plan.resource_creations.map do |resource_creation|
|
52
|
+
# "#{resource_creation.type}.#{resource_creation.name}"
|
53
|
+
# end
|
54
|
+
# "\nexpected: a plan with a resource creation for type: #{type}" \
|
55
|
+
# "\n got: a plan with resource creations:" \
|
56
|
+
# "\n - #{resource_creations.join("\n - ")}"
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# failure_message_when_negated do |plan|
|
60
|
+
# resource_creations = plan.resource_creations.map do |resource_creation|
|
61
|
+
# "#{resource_creation.type}.#{resource_creation.name}"
|
62
|
+
# end
|
63
|
+
# "\nexpected: a plan without a resource creation for type: #{type}" \
|
64
|
+
# "\n got: a plan with resource creations:" \
|
65
|
+
# "\n - #{resource_creations.join("\n - ")}"
|
66
|
+
# end
|
67
|
+
# end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './matchers/include_resource_change'
|
4
|
+
|
5
|
+
module RSpec
|
6
|
+
module Terraform
|
7
|
+
module Matchers
|
8
|
+
def include_resource_change(definition = {})
|
9
|
+
IncludeResourceChange.new(definition)
|
10
|
+
end
|
11
|
+
|
12
|
+
def include_resource_creation(definition = {})
|
13
|
+
include_resource_change(definition.merge(create?: true))
|
14
|
+
end
|
15
|
+
|
16
|
+
def include_resource_read(definition = {})
|
17
|
+
include_resource_change(definition.merge(read?: true))
|
18
|
+
end
|
19
|
+
|
20
|
+
def include_resource_update(definition = {})
|
21
|
+
include_resource_change(definition.merge(update?: true))
|
22
|
+
end
|
23
|
+
|
24
|
+
def include_resource_replacement(definition = {})
|
25
|
+
include_resource_change(definition.merge(replace?: true))
|
26
|
+
end
|
27
|
+
|
28
|
+
def include_resource_deletion(definition = {})
|
29
|
+
include_resource_change(definition.merge(delete?: true))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rspec/terraform/version'
|
6
|
+
|
7
|
+
files = %w[
|
8
|
+
bin
|
9
|
+
lib
|
10
|
+
CODE_OF_CONDUCT.md
|
11
|
+
rspec-terraform.gemspec
|
12
|
+
Gemfile
|
13
|
+
LICENSE.txt
|
14
|
+
Rakefile
|
15
|
+
README.md
|
16
|
+
]
|
17
|
+
|
18
|
+
Gem::Specification.new do |spec|
|
19
|
+
spec.name = 'rspec-terraform'
|
20
|
+
spec.version = RSpec::Terraform::VERSION
|
21
|
+
spec.authors = ['InfraBlocks Maintainers']
|
22
|
+
spec.email = ['maintainers@infrablocks.io']
|
23
|
+
|
24
|
+
spec.summary = 'RSpec support for testing Terraform configurations.'
|
25
|
+
spec.description =
|
26
|
+
'Helpers, contexts and matchers to support using RSpec to test Terraform ' \
|
27
|
+
'configurations and modules.'
|
28
|
+
spec.homepage = 'https://github.com/infrablocks/rspec-terraform'
|
29
|
+
spec.license = 'MIT'
|
30
|
+
|
31
|
+
spec.files = `git ls-files -z`.split("\x0").select do |f|
|
32
|
+
f.match(/^(#{files.map { |g| Regexp.escape(g) }.join('|')})/)
|
33
|
+
end
|
34
|
+
spec.bindir = 'exe'
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ['lib']
|
37
|
+
|
38
|
+
spec.required_ruby_version = '>= 2.7'
|
39
|
+
|
40
|
+
spec.add_dependency 'rspec', '>= 3.0'
|
41
|
+
spec.add_dependency 'ruby-terraform', '1.7.0.pre.1'
|
42
|
+
|
43
|
+
spec.add_development_dependency 'bundler'
|
44
|
+
spec.add_development_dependency 'faker'
|
45
|
+
spec.add_development_dependency 'gem-release'
|
46
|
+
spec.add_development_dependency 'rake'
|
47
|
+
spec.add_development_dependency 'rake_circle_ci'
|
48
|
+
spec.add_development_dependency 'rake_github'
|
49
|
+
spec.add_development_dependency 'rake_gpg'
|
50
|
+
spec.add_development_dependency 'rake_ssh'
|
51
|
+
spec.add_development_dependency 'rubocop'
|
52
|
+
spec.add_development_dependency 'rubocop-rake'
|
53
|
+
spec.add_development_dependency 'rubocop-rspec'
|
54
|
+
spec.add_development_dependency 'simplecov'
|
55
|
+
|
56
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-terraform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- InfraBlocks Maintainers
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ruby-terraform
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.7.0.pre.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.7.0.pre.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faker
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gem-release
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake_circle_ci
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake_github
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake_gpg
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake_ssh
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop-rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop-rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
description: Helpers, contexts and matchers to support using RSpec to test Terraform
|
210
|
+
configurations and modules.
|
211
|
+
email:
|
212
|
+
- maintainers@infrablocks.io
|
213
|
+
executables: []
|
214
|
+
extensions: []
|
215
|
+
extra_rdoc_files: []
|
216
|
+
files:
|
217
|
+
- CODE_OF_CONDUCT.md
|
218
|
+
- Gemfile
|
219
|
+
- Gemfile.lock
|
220
|
+
- LICENSE.txt
|
221
|
+
- README.md
|
222
|
+
- Rakefile
|
223
|
+
- bin/console
|
224
|
+
- bin/setup
|
225
|
+
- lib/rspec/terraform.rb
|
226
|
+
- lib/rspec/terraform/matchers.rb
|
227
|
+
- lib/rspec/terraform/matchers/include_resource_change.rb
|
228
|
+
- lib/rspec/terraform/version.rb
|
229
|
+
- rspec-terraform.gemspec
|
230
|
+
homepage: https://github.com/infrablocks/rspec-terraform
|
231
|
+
licenses:
|
232
|
+
- MIT
|
233
|
+
metadata:
|
234
|
+
rubygems_mfa_required: 'false'
|
235
|
+
post_install_message:
|
236
|
+
rdoc_options: []
|
237
|
+
require_paths:
|
238
|
+
- lib
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '2.7'
|
244
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - ">"
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: 1.3.1
|
249
|
+
requirements: []
|
250
|
+
rubygems_version: 3.1.6
|
251
|
+
signing_key:
|
252
|
+
specification_version: 4
|
253
|
+
summary: RSpec support for testing Terraform configurations.
|
254
|
+
test_files: []
|