Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to setup control repo #794

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions lib/rspec-puppet/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ def self.run(module_name=nil)
end

safe_setup_directories(module_name)
safe_setup_links(module_name)
safe_touch(File.join('spec', 'fixtures', 'manifests', 'site.pp'))

safe_create_spec_helper
safe_create_rakefile
end

def self.safe_setup_directories(module_name=nil, verbose=true)
if control_repo?
$stderr.puts "Unable to setup rspec-puppet automatically in a control repo" if verbose
return false
end

if module_name.nil?
module_name = get_module_name
if module_name.nil?
Expand All @@ -54,6 +50,20 @@ def self.safe_setup_directories(module_name=nil, verbose=true)
File.join('spec', 'fixtures', 'manifests'),
File.join('spec', 'fixtures', 'modules'),
].each { |dir| safe_mkdir(dir, verbose) }
end

def self.safe_setup_links(module_name=nil)
if control_repo?
$stderr.puts "Unable to setup rspec-puppet symlinks in a control repo" if verbose
return false
end
if module_name.nil?
module_name = get_module_name
if module_name.nil?
$stderr.puts "Unable to determine module name. Aborting"
return false
end
end

target = File.join('spec', 'fixtures', 'modules', module_name)
safe_make_link('.', target, verbose)
Expand Down