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') File.open('.rspec','w') do |f| f.write <<-CONTENT r at progress T end 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_p('spec') File.open('spec/spec_helper.rb','w') do |f| f.write <<-CONTENT file was generated by the `rspec --init` command. Conventionally, all s live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. ire this file using `require "spec_helper.rb"` to ensure that it is only ed once. http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration configure do |config| ig.treat_symbols_as_metadata_keys_with_true_values = true ig.run_all_when_everything_filtered = true ig.filter_run :focus T end 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