module RspecFileChef::DirInitializer

Constants

HELPER_PATH

Attributes

rspec_path[R]
test_dir[R]
tmp_dir[R]

Private Instance Methods

any_custom_path(&block) click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 36
def any_custom_path(&block)
  custom_paths.any?(&block)
end
check_config() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 44
def check_config
  raise Error::CONFIG if any_custom_path(&:nil?)
  true
end
check_custom_paths() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 54
def check_custom_paths
  raise Error::CUSTOM_PATHS if any_custom_path(&not_exist?)
end
create_helper_dir() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 58
def create_helper_dir
  %w[temp_data test_data].map do |path|
    path = "#{rspec_path}/#{HELPER_PATH}/#{path}"
    FileUtils.mkdir_p(path)
    path
  end
end
custom_paths() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 32
def custom_paths
  [custom_tmp_dir, custom_test_dir]
end
custom_paths_needed?() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 49
def custom_paths_needed?
  return false if rspec_path
  check_config
end
custom_test_dir() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 21
def custom_test_dir
  self.class.config.custom_test_dir
end
custom_tmp_dir() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 17
def custom_tmp_dir
  self.class.config.custom_tmp_dir
end
default_rspec_path() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 13
def default_rspec_path
  self.class.config.rspec_path
end
not_exist?() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 40
def not_exist?
  lambda { |path| !Dir.exist?(path) }
end
rspec_pattern() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 9
def rspec_pattern
  %r{\A.+?(?=\/spec(\/|\z))}
end
set_dir_paths() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 66
def set_dir_paths
  @tmp_dir, @test_dir =
    if custom_paths_needed?
      check_custom_paths
      custom_paths
    else
      create_helper_dir
    end
end
set_rspec_path() click to toggle source
# File lib/rspec_file_chef/dir_initializer.rb, line 25
def set_rspec_path
  return unless default_rspec_path
  path = default_rspec_path[/#{rspec_pattern}/]
  raise Error::RSPEC_PATH unless path
  @rspec_path = "#{path}/spec"
end