beaker-module_install_helper 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 335eced6501675a1215d9492779c7efca77c62bc
4
- data.tar.gz: 32c5045a4faed8fc92bc44e019164f6d711b9176
3
+ metadata.gz: 7f42bb555dae48d87cf1130b46c794a807ae06c6
4
+ data.tar.gz: f8f649a6dbadd789bd5ccce94893f65d3d05edd5
5
5
  SHA512:
6
- metadata.gz: 53e39c82c94044ee48d18d07004b47dd0e55dc90427f976e924a49044c6416c1d2a7080dda980420372a7947f62bd04fd87ef518736152f79fdb27b55ce180d6
7
- data.tar.gz: 23e6824f988c904633fde2338bce5fb72c4950a1cefa093df1113cbc43ef1551ea43dbc9b772c3e0855066e07acd797c890dc66a47c03a7aca1ccb31d46f39fb
6
+ metadata.gz: d21312fee8851d74a85ea5363b8b6b93df78a9573d25cbb1c3483158563f6e65eed574b794c9fe5dc06fabfff08ac130e1f59d2ac2e9da918051b3341c8b2bfc
7
+ data.tar.gz: deb63867b68ab82b6ce302021d38dc6ee8f97b21172083cdaccb5770ea7611b0d331a9f5ee8b0b0a33c6b1ea680adb3c36654897664db33f84b2a1b7c6691eaf
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'beaker-module_install_helper'
7
- spec.version = '0.1.3'
7
+ spec.version = '0.1.4'
8
8
  spec.authors = ['Puppet']
9
9
  spec.email = ['wilson@puppet.com']
10
10
 
@@ -153,7 +153,14 @@ module Beaker::ModuleInstallHelper
153
153
 
154
154
  # Use this property to store the module_source_dir, so we don't traverse
155
155
  # the tree every time
156
- def get_module_source_directory(search_in)
156
+ def get_module_source_directory(call_stack)
157
+ matching_caller = call_stack.select { |i| i =~ /(spec_helper_acceptance|_spec)/i }
158
+
159
+ raise 'Error finding module source directory' if matching_caller.empty?
160
+
161
+ matching_caller = matching_caller[0] if matching_caller.is_a?(Array)
162
+ search_in = matching_caller[/[^:]+/]
163
+
157
164
  module_source_dir = nil
158
165
  # here we go up the file tree and search the directories for a
159
166
  # valid metadata.json
@@ -193,4 +200,4 @@ end
193
200
 
194
201
  include Beaker::ModuleInstallHelper
195
202
  # Use the caller (requirer) of this file to begin search for module source dir
196
- $module_source_dir = get_module_source_directory caller[0][/[^:]+/]
203
+ $module_source_dir = get_module_source_directory caller
@@ -50,8 +50,8 @@ describe Beaker::ModuleInstallHelper do
50
50
  end
51
51
 
52
52
  context 'get_module_source_directory' do
53
- let(:search_in) { '/a/b/c/d/e/f/g/h.rb' }
54
- let(:search_in_no_metadata) { '/test/test/test/blah.rb' }
53
+ let(:call_stack) { ['/a/b/c/d/e/f/g/spec_helper_acceptance.rb'] }
54
+ let(:call_stack_no_metadata) { ['/test/test/test/spec_helper_acceptance.rb'] }
55
55
 
56
56
  before do
57
57
  allow(File).to receive(:exist?).with(anything).and_return(false)
@@ -59,11 +59,11 @@ describe Beaker::ModuleInstallHelper do
59
59
  end
60
60
 
61
61
  it 'traverses file tree until it finds a folder containing metadata.json' do
62
- expect(get_module_source_directory(search_in)).to eq('/a')
62
+ expect(get_module_source_directory(call_stack)).to eq('/a')
63
63
  end
64
64
 
65
65
  it 'traverses file tree without a metadata.json file' do
66
- expect(get_module_source_directory(search_in_no_metadata)).to be_nil
66
+ expect(get_module_source_directory(call_stack_no_metadata)).to be_nil
67
67
  end
68
68
  end
69
69
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-module_install_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec