class RSpec::Core::ProjectInitializer
def create_dot_rspec_file
def create_dot_rspec_file if File.exist?('.rspec') report_exists('.rspec') else report_creating('.rspec') FileUtils.touch('.rspec') end end
def create_spec_helper_file
def create_spec_helper_file if File.exist?('spec/spec_helper.rb') report_exists("spec/spec_helper.rb") else report_creating("spec/spec_helper.rb") FileUtils.mkdir('spec') unless File.exist?('spec') && File.directory?('spec') FileUtils.touch('spec/spec_helper.rb') end end
def delete_if_confirmed(path, message)
def delete_if_confirmed(path, message) if File.exist?(path) puts puts message puts puts " delete #{path}? [y/n]" FileUtils.rm_rf(path) if gets =~ /y/i end end
def initialize(arg=nil)
def initialize(arg=nil) @arg = arg end
def report_creating(file)
def report_creating(file) puts " create #{file}" end
def report_exists(file)
def report_exists(file) puts " exist #{file}" end
def run
def run warn "The --configure option no longer needs any arguments, so #{@arg} was ignored." if @arg create_spec_helper_file create_dot_rspec_file delete_if_confirmed("autotest/discover.rb", <<-MESSAGE) c registers its own discover.rb with Autotest, so autotest/discover.rb is onger needed. MESSAGE delete_if_confirmed("lib/tasks/rspec.rake", <<-MESSAGE) he file in lib/tasks/rspec.rake is the one generated by rspec-rails-1x, can get rid of it, as it is no longer needed with rspec-2. MESSAGE end