# File lib/rspec/core/project_initializer.rb, line 4 def initialize(arg=nil) @arg = arg end
# File lib/rspec/core/project_initializer.rb, line 23 def create_dot_rspec_file if File.exist?('.rspec') report_exists('.rspec') else report_creating('.rspec') File.open('.rspec','w') do |f| f.write "--color --format progress " end end end
# File lib/rspec/core/project_initializer.rb, line 37 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 "# This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # Require this file using `require "spec_helper.rb"` to ensure that it is only # loaded once. # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus end " end end end
# File lib/rspec/core/project_initializer.rb, line 61 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 =~ %ry/ end end
# File lib/rspec/core/project_initializer.rb, line 75 def report_creating(file) puts " create #{file}" end
# File lib/rspec/core/project_initializer.rb, line 71 def report_exists(file) puts " exist #{file}" end
# File lib/rspec/core/project_initializer.rb, line 8 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", " RSpec registers its own discover.rb with Autotest, so autotest/discover.rb is no longer needed. ") delete_if_confirmed("lib/tasks/rspec.rake", " If the file in lib/tasks/rspec.rake is the one generated by rspec-rails-1x, you can get rid of it, as it is no longer needed with rspec-2. ") end