Class: RSpec::Core::ProjectInitializer

### Home Classes Methods

### In Files

- lib/rspec/core/project_initializer.rb

### Parent

Object

### Methods

- ::new
- #create_dot_rspec_file
- #create_spec_helper_file
- #delete_if_confirmed
- #report_creating
- #report_exists
- #run

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::BacktraceCleaner
- RSpec::Core::BacktraceFormatter
- RSpec::Core::CommandLine
- RSpec::Core::Configuration
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::ConstMissing
- RSpec::Core::DRbCommandLine
- RSpec::Core::DSL
- RSpec::Core::Deprecation
- RSpec::Core::DrbOptions
- RSpec::Core::Example
- RSpec::Core::Example::NotPendingExampleFixed
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::Extensions
- RSpec::Core::Extensions::InstanceEvalWithArgs
- RSpec::Core::Extensions::ModuleEvalWithArgs
- RSpec::Core::Extensions::Ordered
- RSpec::Core::Extensions::Ordered::ExampleGroups
- RSpec::Core::Extensions::Ordered::Examples
- RSpec::Core::FilterManager
- RSpec::Core::FilterManager::BackwardCompatibility
- RSpec::Core::FilterManager::Describable
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::Formatters::TextMateFormatter
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterAllHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::AroundHookCollection
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::GroupHookCollection
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollection
- RSpec::Core::Hooks::HookCollectionAliases
- RSpec::Core::Hooks::RegistersGlobals
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::BeforeAllMemoizedHash
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleMetadataHash
- RSpec::Core::Metadata::GroupMetadataHash
- RSpec::Core::Metadata::MetadataHash
- RSpec::Core::MetadataHashBuilder
- RSpec::Core::MetadataHashBuilder::Common
- RSpec::Core::MetadataHashBuilder::WithConfigWarning
- RSpec::Core::MetadataHashBuilder::WithDeprecationWarning
- RSpec::Core::MockFrameworkAdapter
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingDeclaredInExample
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Collection
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::World
- RSpec::Rake
- RSpec::Runner
- Autotest
- Autotest::Rspec2
- Kernel

No matching classes.

# RSpec::Core::ProjectInitializer

### Public Class Methods

new(arg=nil) click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 4
    def initialize(arg=nil)
      @arg = arg
    end

### Public Instance Methods

create_dot_rspec_file() click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 22
    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

create_spec_helper_file() click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 36
    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"` to ensure that it is only# loaded once.## See http://rubydoc.info/gems/rspec-core/RSpec/Core/ConfigurationRSpec.configure do |config|  config.treat_symbols_as_metadata_keys_with_true_values = true  config.run_all_when_everything_filtered = true  config.filter_run :focus  # Run specs in random order to surface order dependencies. If you find an  # order dependency and want to debug it, you can fix the order by providing  # the seed, which is printed after each run.  #     --seed 1234  config.order = 'random'end
        end
      end
    end

delete_if_confirmed(path, message) click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 66
    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/
      end
    end

report_creating(file) click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 80
    def report_creating(file)
      puts "  create   #{file}"
    end

report_exists(file) click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 76
    def report_exists(file)
      puts "   exist   #{file}"
    end

run() click to toggle source

    # File lib/rspec/core/project_initializer.rb, line 8
    def run
      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

[Validate]

Generated with the Darkfish Rdoc Generator 2.