Class: RSpec::Core::CommandLineConfiguration::Autotest

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/command_line_configuration.rb

Class Method Summary collapse

Class Method Details

.create_dot_rspec_fileObject



33
34
35
36
37
38
39
40
41
# File 'lib/rspec/core/command_line_configuration.rb', line 33

def create_dot_rspec_file
  puts "Autotest loads RSpec's Autotest subclass when there is a .rspec file in the project's root directory."
  if File.exist?('./.rspec')
    puts ".rspec file already exists, so nothing was changed."
  else
    FileUtils.touch('./.rspec')
    puts ".rspec file did not exist, so it was created."
  end
end

.discover_file_exists?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/rspec/core/command_line_configuration.rb', line 51

def discover_file_exists?
  File.exist?(discover_file_path)
end

.discover_file_pathObject



55
56
57
# File 'lib/rspec/core/command_line_configuration.rb', line 55

def discover_file_path
  File.join('autotest', 'discover.rb')
end

.generateObject



28
29
30
31
# File 'lib/rspec/core/command_line_configuration.rb', line 28

def generate
  create_dot_rspec_file
  remove_autotest_dir_if_present
end

.remove_autotest_dir_if_presentObject



43
44
45
46
47
48
49
# File 'lib/rspec/core/command_line_configuration.rb', line 43

def remove_autotest_dir_if_present
  if discover_file_exists?
    print "Delete obsolete autotest/discover.rb [y/n]? "
    exit if gets !~ /y/i
    FileUtils.rm_rf(discover_file_path)
  end
end