control_spec_helper 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +13 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile.lock +109 -0
  7. data/Rakefile +87 -8
  8. data/control_spec_helper.gemspec +22 -15
  9. data/ext/spec_helper_control.rb +8 -5
  10. data/lib/control_spec_helper/control_spec_helper.rb +49 -32
  11. data/lib/control_spec_helper/rake_tasks.rb +1 -157
  12. data/lib/control_spec_helper/version.rb +1 -1
  13. data/lib/rake_tasks.rb +4 -0
  14. data/lib/slalom.rb +60 -0
  15. data/lib/tasks/acceptance.rake +26 -0
  16. data/lib/tasks/apply.rake +7 -0
  17. data/lib/tasks/apply_debug.rake +7 -0
  18. data/lib/tasks/apply_dev.rake +7 -0
  19. data/lib/tasks/apply_noop.rake +6 -0
  20. data/lib/tasks/apply_standalone.rake +7 -0
  21. data/lib/tasks/default.rake +3 -0
  22. data/lib/tasks/git.rake +9 -0
  23. data/lib/tasks/help.rake +6 -0
  24. data/lib/tasks/hooks.rake +11 -0
  25. data/lib/tasks/lint.rake +26 -0
  26. data/lib/tasks/puppet_cmd.rake +6 -0
  27. data/lib/tasks/r10k.rake +6 -0
  28. data/lib/tasks/serverspec.rake +10 -0
  29. data/lib/tasks/spec.rake +10 -0
  30. data/lib/tasks/spec_clean.rake +6 -0
  31. data/lib/tasks/spec_prep.rake +10 -0
  32. data/lib/tasks/vplugins.rake +9 -0
  33. data/spec/spec_helper.rb +11 -0
  34. data/spec/support/shared_contexts/rake.rb +26 -0
  35. data/spec/tasks/vplugins_spec.rb +71 -0
  36. data/spec/unit/class_from_path_spec.rb +62 -0
  37. data/spec/unit/control_spec_helper_spec.rb +62 -1
  38. data/spec/unit/debug_spec.rb +30 -0
  39. data/spec/unit/diff_from_base_spec.rb +34 -0
  40. data/spec/unit/diff_profile_spec.rb +38 -0
  41. data/spec/unit/diff_roles_spec.rb +38 -0
  42. data/spec/unit/profile_fixtures_spec.rb +185 -0
  43. data/spec/unit/project_root_spec.rb +45 -0
  44. data/spec/unit/r10k_spec.rb +58 -0
  45. data/spec/unit/spec_clean_spec.rb +137 -0
  46. data/spec/unit/spec_from_class_spec.rb +65 -0
  47. metadata +148 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85c0b9b72a42803e64e735178baa10091aa89782
4
- data.tar.gz: 1414e84d2bb520b8310533b2f3fe2504c18d4127
3
+ metadata.gz: 18bbd384c54c74eb7500a318c068b5d43b60a85f
4
+ data.tar.gz: d44d869e7c98330024040ee22388f61e9ded4138
5
5
  SHA512:
6
- metadata.gz: b5ea6ca1108204d0e87dbf83bcf8bce8ffa07a9681904c67415092e2388745054191168e80397a4d28c8eb7ebaffc84e024065dcff2e923f54de806a97a8f7c4
7
- data.tar.gz: deff607652448f633a89bb1fa03b0de77aac9ffe87482cf4aaf43ff8c96494e454d1922fc739118c8e4d79990ca8a5e0ecd9dd72ae493544b76ca12aed2b24fe
6
+ metadata.gz: ae8ce1c9f36c360f110b9dfc358d5510e96a096904a5533810c2fc8f6eb5715e168e1b86c7187a7c0647bc194d14d361ecde8aad959caa58ca0376ae3efe4f85
7
+ data.tar.gz: 3a19bee071a8bf631ec03279da5848819cd0768858cf81b8cf654c32f6ffbf25b24cfe98a3274dcb47c4a71a704344ed2c1357fe291dc47e3315805485ea6dc7
data/.gitignore CHANGED
@@ -1,3 +1,7 @@
1
- Gemfile.lock
2
1
  pkg/
3
2
  .*.sw
3
+ *.swp
4
+ fixtures/puppet-control/*
5
+ *.*~
6
+ .bundle/*
7
+ vendor/*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --tty
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'fixtures/**/*'
4
+ Metrics/AbcSize:
5
+ Severity: warning
6
+ Metrics/CyclomaticComplexity:
7
+ Severity: warning
8
+ Metrics/LineLength:
9
+ Severity: warning
10
+ Metrics/ModuleLength:
11
+ Severity: warning
12
+ Metrics/PerceivedComplexity:
13
+ Severity: warning
@@ -0,0 +1 @@
1
+ 2.2.2
@@ -0,0 +1,109 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ control_spec_helper (0.0.2)
5
+ mocha (~> 1.1)
6
+ puppet (~> 4.0)
7
+ puppet-lint (~> 1.1)
8
+ puppet-syntax (~> 2.1)
9
+ rake (~> 11.0)
10
+ rspec-puppet (~> 2.4)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ CFPropertyList (2.2.8)
16
+ ast (2.2.0)
17
+ coderay (1.1.1)
18
+ colored (1.2)
19
+ cri (2.6.1)
20
+ colored (~> 1.2)
21
+ diff-lcs (1.2.5)
22
+ facter (2.4.6)
23
+ CFPropertyList (~> 2.2.6)
24
+ faraday (0.9.2)
25
+ multipart-post (>= 1.2, < 3)
26
+ faraday_middleware (0.10.0)
27
+ faraday (>= 0.7.4, < 0.10)
28
+ git (1.3.0)
29
+ hiera (3.1.2)
30
+ json_pure
31
+ json_pure (1.8.3)
32
+ log4r (1.1.10)
33
+ metaclass (0.0.4)
34
+ method_source (0.8.2)
35
+ minitar (0.5.4)
36
+ mocha (1.1.0)
37
+ metaclass (~> 0.0.1)
38
+ multi_json (1.11.3)
39
+ multipart-post (2.0.0)
40
+ net-ssh (3.1.1)
41
+ parser (2.3.1.0)
42
+ ast (~> 2.2)
43
+ powerpack (0.1.1)
44
+ pry (0.10.3)
45
+ coderay (~> 1.1.0)
46
+ method_source (~> 0.8.1)
47
+ slop (~> 3.4)
48
+ puppet (4.4.2)
49
+ CFPropertyList (~> 2.2.6)
50
+ facter (> 2.0, < 4)
51
+ hiera (>= 2.0, < 4)
52
+ json_pure
53
+ puppet-lint (1.1.0)
54
+ puppet-syntax (2.1.0)
55
+ rake
56
+ puppet_forge (2.1.5)
57
+ faraday (~> 0.9.0)
58
+ faraday_middleware (>= 0.9.0, < 0.11.0)
59
+ minitar
60
+ semantic_puppet (~> 0.1.0)
61
+ r10k (2.2.2)
62
+ colored (= 1.2)
63
+ cri (~> 2.6.1)
64
+ log4r (= 1.1.10)
65
+ minitar
66
+ multi_json (~> 1.10)
67
+ puppet_forge (~> 2.1.5)
68
+ semantic_puppet (~> 0.1.0)
69
+ rainbow (2.1.0)
70
+ rake (11.1.2)
71
+ rspec (3.4.0)
72
+ rspec-core (~> 3.4.0)
73
+ rspec-expectations (~> 3.4.0)
74
+ rspec-mocks (~> 3.4.0)
75
+ rspec-core (3.4.4)
76
+ rspec-support (~> 3.4.0)
77
+ rspec-expectations (3.4.0)
78
+ diff-lcs (>= 1.2.0, < 2.0)
79
+ rspec-support (~> 3.4.0)
80
+ rspec-mocks (3.4.1)
81
+ diff-lcs (>= 1.2.0, < 2.0)
82
+ rspec-support (~> 3.4.0)
83
+ rspec-puppet (2.4.0)
84
+ rspec
85
+ rspec-support (3.4.1)
86
+ rubocop (0.39.0)
87
+ parser (>= 2.3.0.7, < 3.0)
88
+ powerpack (~> 0.1)
89
+ rainbow (>= 1.99.1, < 3.0)
90
+ ruby-progressbar (~> 1.7)
91
+ unicode-display_width (~> 1.0, >= 1.0.1)
92
+ ruby-progressbar (1.8.0)
93
+ semantic_puppet (0.1.1)
94
+ slop (3.6.0)
95
+ unicode-display_width (1.0.3)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ control_spec_helper!
102
+ git (~> 1.3)
103
+ net-ssh (~> 3.1)
104
+ pry (~> 0.10)
105
+ r10k (~> 2.2)
106
+ rubocop (~> 0.39)
107
+
108
+ BUNDLED WITH
109
+ 1.11.2
data/Rakefile CHANGED
@@ -2,14 +2,18 @@ require 'rake'
2
2
  require 'rake/packagetask'
3
3
  require 'rubygems/package_task'
4
4
  require 'rspec/core/rake_task'
5
+ require 'git'
6
+ require 'net/ssh'
7
+ require './lib/slalom'
5
8
 
6
9
  task :default do
7
- sh %{rake -T}
10
+ sh %(rake -T)
8
11
  end
9
12
 
10
13
  require 'fileutils'
11
14
 
12
15
  RSpec::Core::RakeTask.new(:spec)
16
+ Rake::Task[:spec].enhance ['fixtures:prep']
13
17
 
14
18
  def version
15
19
  require 'control_spec_helper/version'
@@ -17,20 +21,95 @@ def version
17
21
  end
18
22
 
19
23
  namespace :package do
20
- desc "Create the gem"
24
+ desc 'Create the gem'
21
25
  task :gem do
22
- spec = Gem::Specification.load("control_spec_helper.gemspec")
23
- Dir.mkdir("pkg") rescue nil
24
- if Gem::Version.new(`gem -v`) >= Gem::Version.new("2.0.0.a")
26
+ spec = Gem::Specification.load('control_spec_helper.gemspec')
27
+ begin
28
+ Dir.mkdir('pkg')
29
+ rescue => e
30
+ puts e
31
+ end
32
+ if Gem::Version.new(`gem -v`) >= Gem::Version.new('2.0.0.a')
25
33
  Gem::Package.build(spec)
26
34
  else
27
35
  Gem::Builder.new(spec).build
28
36
  end
29
- FileUtils.move("control_spec_helper-#{version}.gem", "pkg")
37
+ FileUtils.move("control_spec_helper-#{version}.gem", 'pkg')
30
38
  end
31
39
  end
32
40
 
33
- desc "Cleanup pkg directory"
41
+ desc 'Run rubocop against tree'
42
+ task :rubocop do
43
+ puts `rubocop`
44
+ end
45
+
46
+ desc 'Cleanup pkg directory'
34
47
  task :clean do
35
- FileUtils.rm_rf("pkg")
48
+ FileUtils.rm_rf('pkg')
49
+ end
50
+
51
+ namespace :fixtures do
52
+ desc 'Prepare fixtures directory'
53
+ task :create do
54
+ FileUtils.mkdir('fixtures') unless File.directory?('fixtures')
55
+ end
56
+
57
+ desc 'Remove fixtures directory'
58
+ task :clean do
59
+ FileUtils.rm_rf('fixtures')
60
+ end
61
+
62
+ desc 'Prepare fixtures repository'
63
+ task prep: [:create, 'package:gem'] do
64
+ begin
65
+ unless File.exist?('fixtures/puppet-control')
66
+ puts 'Cloning puppet_control repository...'
67
+ Git.clone('https://github.com/slalompdx/puppet-control.git',
68
+ 'puppet-control',
69
+ path: 'fixtures',
70
+ branch: 'fixture')
71
+ end
72
+ Bundler.with_clean_env do
73
+ Dir.chdir("#{File.dirname(__FILE__)}/fixtures/puppet-control") do
74
+ puts 'Copying control_spec_helper into fixtures'
75
+ FileUtils.mkdir(
76
+ "#{File.dirname(__FILE__)}/fixtures/puppet-control/csh"
77
+ ) unless File.exist?(
78
+ "#{File.dirname(__FILE__)}/fixtures/puppet-control/csh"
79
+ )
80
+ FileUtils.cp(
81
+ "#{File.dirname(__FILE__)}/pkg/control_spec_helper-#{version}.gem",
82
+ "#{File.dirname(__FILE__)}/fixtures/puppet-control/csh"
83
+ )
84
+ FileUtils.mkdir_p("#{File.dirname(__FILE__)}/fixtures/"\
85
+ 'puppet-control/vendor/gems')
86
+ `gem unpack \
87
+ #{File.dirname(__FILE__)}/fixtures/puppet-control/csh/*.gem \
88
+ --target=./fixtures/puppet-control/vendor/gems/`
89
+ puts 'Bringing up test VM...'
90
+ IO.popen('unset RUBYLIB ; vagrant up') do |io|
91
+ io.each { |s| print s }
92
+ end
93
+ c = vagrant_ssh_config
94
+ Net::SSH.start(
95
+ c['HostName'],
96
+ c['User'],
97
+ port: c['Port'],
98
+ password: 'vagrant'
99
+ ) do |ssh|
100
+ puts 'Installing control_spec_helper gem...'
101
+ ssh.exec!(
102
+ 'cd /vagrant && gem install ./csh/*.gem --no-ri --no-rdoc'
103
+ )
104
+ puts 'Running bundle install...'
105
+ ssh.exec!('cd /vagrant && bundle install')
106
+ puts 'Installing vagrant...'
107
+ puts ssh.exec!('sudo rpm -ivh https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm')
108
+ end
109
+ end
110
+ end
111
+ ensure
112
+ `bundle config --delete local.control_spec_helper`
113
+ end
114
+ end
36
115
  end
@@ -1,26 +1,33 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
- require "control_spec_helper/version"
2
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
+ require 'control_spec_helper/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "control_spec_helper"
6
+ s.name = 'control_spec_helper'
7
7
  s.version = ControlSpecHelper::Version::STRING
8
- s.authors = ["Slalom Consulting"]
9
- s.email = ["eric.shamow@slalom.com"]
10
- s.homepage = "http://github.com/eshamow/control_spec_helper"
11
- s.summary = "Standard tasks and configuration for control repo spec tests"
12
- s.description = "Contains rake tasks and a standard spec_helper for running spec tests on puppet control repo"
8
+ s.authors = ['Slalom Consulting']
9
+ s.email = ['eric.shamow@slalom.com']
10
+ s.homepage = 'http://github.com/eshamow/control_spec_helper'
11
+ s.summary = 'Standard tasks and configuration for control repo spec tests'
12
+ s.description = 'Contains rake tasks and a standard spec_helper for ' \
13
+ 'running spec tests on puppet control repo'
13
14
  s.licenses = 'Apache-2.0'
14
15
 
15
16
  s.files = `git ls-files`.split("\n")
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.executables = `git ls-files -- bin/*`.split("\n")
19
+ .map { |f| File.basename(f) }
18
20
 
19
21
  # Runtime dependencies, but also probably dependencies of requiring projects
20
- s.add_runtime_dependency 'rake'
21
- s.add_runtime_dependency 'rspec-puppet'
22
- s.add_runtime_dependency 'puppet-lint'
23
- s.add_runtime_dependency 'puppet-syntax'
24
- s.add_runtime_dependency 'mocha'
25
- s.add_development_dependency 'pry'
22
+ s.add_runtime_dependency 'rake', '~> 11.0'
23
+ s.add_runtime_dependency 'rspec-puppet', '~> 2.4'
24
+ s.add_runtime_dependency 'puppet', '~> 4.0'
25
+ s.add_runtime_dependency 'puppet-lint', '~> 1.1'
26
+ s.add_runtime_dependency 'puppet-syntax', '~> 2.1'
27
+ s.add_runtime_dependency 'mocha', '~> 1.1'
28
+ s.add_development_dependency 'pry', '~> 0.10'
29
+ s.add_development_dependency 'git', '~> 1.3'
30
+ s.add_development_dependency 'rubocop', '~> 0.39'
31
+ s.add_development_dependency 'r10k', '~> 2.2'
32
+ s.add_development_dependency 'net-ssh', '~> 3.1'
26
33
  end
@@ -6,7 +6,7 @@ else
6
6
  require 'beaker-rspec/spec_helper'
7
7
  require 'beaker-rspec/helpers/serverspec'
8
8
 
9
- UNSUPPORTED_PLATFORMS = %w(Suse windows AIX Solaris Debian)
9
+ UNSUPPORTED_PLATFORMS = %w(Suse windows AIX Solaris Debian).freeze
10
10
 
11
11
  RSpec.configure do |c|
12
12
  # Project root
@@ -30,9 +30,12 @@ else
30
30
  shell 'chown vagrant /controlrepo'
31
31
  install_package(host, 'zlib-devel')
32
32
  install_package(host, 'openssl-devel')
33
- %x{scp -i ~/.vagrant.d/insecure_private_key -o StrictHostKeyChecking=no -r #{proj_root} vagrant@#{host.connection.ip}:/}
34
- #scp_to host, proj_root, '/controlrepo'
35
- shell 'cd /controlrepo && gem install ./control_spec_helper-0.0.1.gem && bundle install && rake r10k'
33
+ shell 'scp -i ~/.vagrant.d/insecure_private_key -o ' \
34
+ "StrictHostKeyChecking=no -r #{proj_root} " \
35
+ "vagrant@#{host.connection.ip}:/"
36
+ # scp_to host, proj_root, '/controlrepo'
37
+ shell 'cd /controlrepo && gem install ./control_spec_helper-0.0.1.gem' \
38
+ '&& bundle install && rake r10k'
36
39
  shell 'mkdir -p /etc/facter/facts.d'
37
40
  role = ENV['role'].sub(/^role::/, '')
38
41
  shell "echo \"role=#{role}\" > /etc/facter/facts.d/role.txt"
@@ -48,7 +51,7 @@ else
48
51
  EOS
49
52
 
50
53
  modulepath = '/controlrepo/dist:/controlrepo/modules'
51
- apply_manifest(pp, :modulepath => modulepath, :catch_failures => true)
54
+ apply_manifest(pp, modulepath: modulepath, catch_failures: true)
52
55
  end
53
56
  end
54
57
  end
@@ -1,7 +1,12 @@
1
- # rubocop:disable Style/DotPosition, Style/HashSyntax
1
+ # rubocop:disable Metrics/ModuleLength
2
2
 
3
+ # Test control repositories, similar to puppetlabs_spec_helper
3
4
  module ControlSpecHelper
4
- attr_writer :basepath, :basebranch
5
+ attr_writer :basepath, :basebranch, :root
6
+
7
+ def file_name
8
+ __FILE__
9
+ end
5
10
 
6
11
  def basepath
7
12
  @basepath ||= 'site'
@@ -12,7 +17,7 @@ module ControlSpecHelper
12
17
  end
13
18
 
14
19
  def debug(msg)
15
- puts "DEBUG: #{msg}" if ENV['debug']
20
+ $stderr.puts "DEBUG: #{msg}" unless ENV['debug'].nil?
16
21
  end
17
22
 
18
23
  def puppet_cmd
@@ -28,46 +33,51 @@ module ControlSpecHelper
28
33
  end
29
34
 
30
35
  def role_path
31
- File.join(project_root, @basepath, 'role')
36
+ @role_path || File.join(project_root, basepath, 'role')
32
37
  end
33
38
 
34
39
  def profile_path
35
- File.join(project_root, @basepath, 'profile')
40
+ @profile_path || File.join(project_root, basepath, 'profile')
36
41
  end
37
42
 
38
43
  def diff_from_base
39
- `git diff #{@basebranch} --cached --diff-filter=ACMR --name-only`.split("\n")
44
+ `git diff #{@basebranch} --cached --diff-filter=ACMR --name-only`
45
+ .split("\n")
40
46
  end
41
47
 
42
48
  def diff_roles
43
- diff_from_base.
44
- select { |file| file.match(%r{site/role/manifests}) }.
45
- map { |path| class_from_path(path) }
49
+ diff_from_base
50
+ .select { |file| file.match(%r{site/role/manifests}) }
51
+ .map { |path| class_from_path(path) }
46
52
  end
47
53
 
48
54
  def diff_profile
49
- diff_from_base.
50
- select { |file| file.match(%r{site/profile/manifests}) }.
51
- map { |path| class_from_path(path) }
55
+ diff_from_base
56
+ .select { |file| file.match(%r{site/profile/manifests}) }
57
+ .map { |path| class_from_path(path) }
52
58
  end
53
59
 
60
+ # This is for role and profile modules only
54
61
  def class_from_path(path)
55
62
  return nil unless path =~ /manifests.+\.pp$/
56
63
 
57
- (path.sub(project_root + '/', '').
58
- sub(/\.pp$/, '').
59
- split('/') - %w(site manifests)).
60
- join('::')
64
+ (path.sub(project_root + '/', '')
65
+ .sub(/\.pp$/, '')
66
+ .split('/') - %w(site manifests))
67
+ .join('::')
61
68
  end
62
69
 
63
70
  def roles_that_include(klass)
71
+ roles = ''
64
72
  Dir.chdir(role_path) do
65
73
  debug("cd to #{role_path}")
66
- `git grep -l #{klass}`.split("\n").
67
- map { |path| class_from_path(File.join(role_path, path)) }.
68
- compact
74
+ roles = `git grep -l #{klass}`
75
+ .split("\n")
76
+ .map { |path| class_from_path(File.join(role_path, path)) }
77
+ .compact
69
78
  end
70
79
  debug "cd to #{Dir.pwd}"
80
+ roles
71
81
  end
72
82
 
73
83
  # TODO: this could be much more accurate if we compiled catalogs for all roles
@@ -80,14 +90,13 @@ module ControlSpecHelper
80
90
 
81
91
  def spec_from_class(klass)
82
92
  test = if klass =~ /profile/
83
- { :path => 'profile', :type => nil }
93
+ { path: 'profile', type: nil }
84
94
  elsif klass =~ /role/
85
- { :path => 'role', :type => 'acceptance' }
95
+ { path: 'role', type: 'acceptance' }
86
96
  else
87
- fail ArgumentError
97
+ raise ArgumentError
88
98
  end
89
-
90
- path = [project_root, @basepath, test[:path], 'spec', test[:type]].compact
99
+ path = [project_root, basepath, test[:path], 'spec', test[:type]].compact
91
100
  File.join(path << (klass.split('::') - [test[:path]])) + '_spec.rb'
92
101
  end
93
102
 
@@ -100,25 +109,32 @@ module ControlSpecHelper
100
109
  debug "cd to #{Dir.pwd}"
101
110
  end
102
111
 
112
+ # rubocop:disable Metrics/AbcSize
113
+ # rubocop:disable Metrics/MethodLength
103
114
  def profile_fixtures
104
115
  Dir.chdir(profile_path) do
116
+ debug(ENV['debug'])
105
117
  debug("cd to #{profile_path}")
106
- profile_ln = './spec/fixtures/modules/profile'
118
+ profile_ln = "#{File.dirname(file_name)}/spec/fixtures/modules/profile"
107
119
 
108
- FileUtils.mkpath './spec/fixtures/modules/'
109
- File.symlink(profile_path, profile_ln) unless File.exists?(profile_ln)
120
+ FileUtils.mkpath "#{File.dirname(file_name)}/spec/fixtures/modules/"
121
+ File.symlink(profile_path, profile_ln) unless File.exist?(profile_ln)
110
122
 
111
- Dir.glob('../../modules/*').each do |folder|
123
+ Dir.glob("#{File.dirname(file_name)}/../../modules/*").each do |folder|
112
124
  next unless File.directory?(folder)
113
- old_path = File.join(File.dirname(__FILE__), folder)
114
- new_path = File.join("./spec/fixtures/modules/#{File.basename(folder)}")
125
+ old_path = File.join(File.dirname(file_name), folder)
126
+ new_path = "#{File.dirname(file_name)}/spec/fixtures/modules/" \
127
+ "#{File.basename(folder)}"
115
128
 
116
129
  File.symlink(old_path, new_path) unless File.symlink?(new_path)
117
130
  end
118
131
  end
119
132
  debug "cd to #{Dir.pwd}"
120
133
  end
134
+ # rubocop:enable Metrics/MethodLength
135
+ # rubocop:enable Metrics/AbcSize
121
136
 
137
+ # rubocop:disable Metrics/AbcSize
122
138
  def spec_clean
123
139
  Dir.chdir(project_root) do
124
140
  debug("cd to #{project_root}")
@@ -128,9 +144,10 @@ module ControlSpecHelper
128
144
  abort if fixtures == '' || !fixtures
129
145
  abort if modules == '' || !modules
130
146
 
131
- `rm -rf #{fixtures}/*`
132
- `rm -rf #{modules}/*`
147
+ FileUtils.rm_rf(fixtures)
148
+ FileUtils.rm_rf(modules)
133
149
  end
134
150
  debug "cd to #{Dir.pwd}"
135
151
  end
152
+ # rubocop:enable Metrics/AbcSize
136
153
  end