From 9f1b4d016d1beb9b04e99a2eb869a2910423b7fe Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 4 Nov 2020 16:15:29 -0600 Subject: [PATCH] Allow users to specify plugins to install in isolated environment --- lib/vagrant-spec/acceptance/configuration.rb | 8 ++++++++ lib/vagrant-spec/acceptance/rspec/context.rb | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-spec/acceptance/configuration.rb b/lib/vagrant-spec/acceptance/configuration.rb index 36a5b90..d7795a1 100644 --- a/lib/vagrant-spec/acceptance/configuration.rb +++ b/lib/vagrant-spec/acceptance/configuration.rb @@ -37,6 +37,14 @@ class Configuration # different depending on mode. attr_accessor :run_mode + # List of plugins to install in the isolated environment + attr_accessor :plugins + + # Map of plugin licenses to install in the isolated environment. Should take + # the form: + # { plugin: path/to/license } + attr_accessor :licenses + def initialize @component_paths = [ Vagrant::Spec.source_root.join("acceptance"), diff --git a/lib/vagrant-spec/acceptance/rspec/context.rb b/lib/vagrant-spec/acceptance/rspec/context.rb index 919221e..43042ff 100644 --- a/lib/vagrant-spec/acceptance/rspec/context.rb +++ b/lib/vagrant-spec/acceptance/rspec/context.rb @@ -35,11 +35,21 @@ def new_environment(env=nil) env = config.env.merge(env || {}) env.merge!(extra_env) - Vagrant::Spec::AcceptanceIsolatedEnvironment.new( + iso_env = Vagrant::Spec::AcceptanceIsolatedEnvironment.new( apps: apps, env: env, skeleton_paths: skeleton_paths, ) + + Array(config.plugins).each do |plugin| + iso_env.execute("vagrant", "plugin", "install", plugin) + end + + Array(config.licenses).each do |plugin, license| + iso_env.execute("vagrant", "plugin", "license", plugin, license) + end + + iso_env end # Executes the given command in the context of the isolated environment.