rspec-terraspace 0.3.0 → 0.3.1

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: c09973fe7ff5551af56434b0cdc5bc97194e4695fcdd061c3c7cfaebbd7d468f
4
- data.tar.gz: eadb2ce4620283dfd666afff0993aee8769217c6a36848ed8ca98bf1d3db8d27
3
+ metadata.gz: 86b718772c65d61edfd892aab57116ec4414f6302162d59c7369090a2864cd50
4
+ data.tar.gz: d27b219c170bd11a122d71ca07f6d06b3f10a3056524f23a4a9a55104b3c8b48
5
5
  SHA512:
6
- metadata.gz: 63571680195d695c14d2bf3633f165f904cadc3145e3f802610ecc6c33386fe57f99a4acb5c9234c05d27b6870137192eb37c759612ff83e27d1dc6eb1202958
7
- data.tar.gz: c524ce214a25bc5d9a54be71a74b1b30130433ed79c8b63f7d716da420c7e161a900ea8b2a18e7b96d5d50084cedcf9cc0cc4619e852cec137329a1c0ced6f07
6
+ metadata.gz: 7cf1300e159a1bd5be2c0ad59236e889b426a83f955829be294b504981290e3da22a5af83835f8bc5b6dafb780e8350835b4acda49a3aa6f349d50a92b1d8002
7
+ data.tar.gz: cd0486c714961d6e4d34e577e2c60b313dcae8112e59affead2a1228588eaf517d5137acbe2cbae9952ded6c9624e0c925fc4f1c221f681ea7c3a91cb5989893
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.3.1] - 2021-12-29
7
+ - [#8](https://github.com/boltops-tools/rspec-terraspace/pull/8) provider autodetection
8
+
6
9
  ## [0.3.0] - 2021-07-26
7
10
  - [#5](https://github.com/boltops-tools/rspec-terraspace/pull/5) Improvements
8
11
  - detect module or stack type so module specs can be written
data/README.md CHANGED
@@ -21,7 +21,7 @@ So if you set it: `export TS_RSPEC_BUILD_ROOT=~/environment/terraspace-test-harn
21
21
 
22
22
  The test helpers support both module-level and project-level tests. See:
23
23
 
24
- * [Terraspace Testing](https://github.com/boltops-tools/terraspace-docs/blob/master/testing.md)
24
+ * [Terraspace Testing](https://terraspace.cloud/docs/testing/)
25
25
 
26
26
  ## Installation
27
27
 
@@ -11,6 +11,7 @@ module RSpec::Terraspace
11
11
  @stacks = options[:stacks]
12
12
  @tfvars = options[:tfvars]
13
13
  @folders = options[:folders]
14
+ @plugin = options[:plugin]
14
15
 
15
16
  @remove_test_folder = options[:remove_test_folder].nil? ? true : options[:remove_test_folder]
16
17
  end
@@ -44,7 +45,29 @@ module RSpec::Terraspace
44
45
  FileUtils.mkdir_p(parent_dir)
45
46
  Dir.chdir(parent_dir) do
46
47
  project_name = File.basename(build_dir)
47
- ::Terraspace::CLI::New::Project.start([project_name, "--no-config", "--quiet"])
48
+ args = [project_name, "--no-config", "--quiet"] + plugin_option
49
+ ::Terraspace::CLI::New::Project.start(args)
50
+ end
51
+ end
52
+
53
+ def plugin_option
54
+ if @plugin
55
+ ["-p", @plugin]
56
+ else
57
+ provider = autodetect_provider || "none"
58
+ ["-p", provider]
59
+ end
60
+ end
61
+
62
+ def autodetect_provider
63
+ providers = Terraspace::Plugin.meta.keys
64
+ if providers.size == 1
65
+ providers.first
66
+ else
67
+ precedence = %w[aws azurerm google]
68
+ precedence.find do |p|
69
+ providers.include?(p)
70
+ end
48
71
  end
49
72
  end
50
73
 
@@ -8,11 +8,20 @@ module RSpec::Terraspace
8
8
  CLI = ::Terraspace::CLI
9
9
 
10
10
  def build_test_harness(options={})
11
+ setup
11
12
  project = Project.new(options)
12
13
  root = project.create
13
14
  Terraspace.root = root # switch root to the generated test harness
14
15
  end
15
16
 
17
+ def setup
18
+ # Require gems in Gemfile so terraspace_plugin_* gets loaded and registered
19
+ # This it test Gemfile. IE: app/stacks/demo/test/Gemfile
20
+ Kernel.require "bundler/setup"
21
+ Bundler.require # Same as Bundler.require(:default)
22
+ Terraspace.check_project = false
23
+ end
24
+
16
25
  def up(args)
17
26
  run("up #{args} -y")
18
27
  mod = args.split(' ').first
@@ -1,5 +1,5 @@
1
1
  module Rspec
2
2
  module Terraspace
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require "rspec/terraspace/version"
2
2
 
3
+ require "active_support"
3
4
  require "active_support/core_ext/class"
4
5
  require "active_support/core_ext/hash"
5
6
  require "active_support/core_ext/string"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-terraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-26 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 3.2.5
142
+ rubygems_version: 3.2.32
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Terraspace RSpec support