Skip to content

Commit 81d2be8

Browse files
committed
Open Autotest class to add class methods. Use matcher for gets.
1 parent 291d316 commit 81d2be8

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

lib/rspec/core/command_line_configuration.rb

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,38 @@ def run
1515
end
1616

1717
class Autotest
18-
def self.generate
19-
create_autotest_directory
20-
create_discover_file
21-
puts "autotest/discover.rb has been added"
22-
end
18+
class << self
19+
def generate
20+
create_autotest_directory
21+
create_discover_file
22+
puts "autotest/discover.rb has been added"
23+
end
2324

24-
def self.create_autotest_directory
25-
Dir.mkdir('autotest') unless File.exist?('autotest')
26-
end
25+
def create_autotest_directory
26+
Dir.mkdir('autotest') unless File.exist?('autotest')
27+
end
2728

28-
def self.create_discover_file
29-
optionally_remove_discover_file if discover_file_exists?
29+
def create_discover_file
30+
optionally_remove_discover_file if discover_file_exists?
3031

31-
File.open(discover_file_path, 'w') do |file|
32-
file << 'Autotest.add_discovery { "rspec2" }'
32+
File.open(discover_file_path, 'w') do |file|
33+
file << 'Autotest.add_discovery { "rspec2" }'
34+
end
3335
end
34-
end
3536

36-
def optionally_remove_discover_file
37-
print "Discover file already exists, overwrite [Y/n]? "
38-
exit if gets != 'Y'
39-
FileUtils.rm_rf(discover_file_path)
40-
end
37+
def optionally_remove_discover_file
38+
print "Discover file already exists, overwrite [y/N]? "
39+
exit if gets !~ /y/i
40+
FileUtils.rm_rf(discover_file_path)
41+
end
4142

42-
def self.discover_file_exists?
43-
File.exist?(discover_file_path)
44-
end
43+
def discover_file_exists?
44+
File.exist?(discover_file_path)
45+
end
4546

46-
def self.discover_file_path
47-
File.join('autotest', 'discover.rb')
47+
def discover_file_path
48+
File.join('autotest', 'discover.rb')
49+
end
4850
end
4951
end
5052
end

0 commit comments

Comments
 (0)