From 132d39066cf13ca3a96f3f4e9c98ef0f30577970 Mon Sep 17 00:00:00 2001 From: Will Hopper Date: Fri, 30 Sep 2016 16:28:57 -0700 Subject: [PATCH] (maint) Add acceptance libdir and Util helper module --- spec/acceptance/lib/util.rb | 15 +++++++++++++++ spec/spec_helper_acceptance.rb | 2 ++ 2 files changed, 17 insertions(+) create mode 100644 spec/acceptance/lib/util.rb diff --git a/spec/acceptance/lib/util.rb b/spec/acceptance/lib/util.rb new file mode 100644 index 0000000..e5a5793 --- /dev/null +++ b/spec/acceptance/lib/util.rb @@ -0,0 +1,15 @@ +module PuppetStrings + module Acceptance + module Util + def read_file_on(host, filename) + on(host, "cat #{filename}").stdout + end + + def get_test_module_path(host, module_regex) + modules = JSON.parse(on(host, puppet('module', 'list', '--render-as', 'json')).stdout) + test_module_info = modules['modules_by_path'].values.flatten.find { |mod_info| mod_info =~ module_regex } + test_module_info.match(/\(([^)]*)\)/)[1] + end + end + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 578fa3c..2eba14c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,6 +1,8 @@ require 'beaker-rspec/spec_helper' require 'beaker-rspec/helpers/serverspec' +$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'acceptance/lib')) + unless ENV['RS_PROVISION'] == 'no' install_puppet end