Sha256: 3d3697a95ea4176d9c200543af54c08eddff6fc018d7cd177905380bcd30080a

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module RSpec
  module Core
    # @private
    # Generates conventional files for an rspec project
    class ProjectInitializer
      def run
        create_spec_helper_file
        create_dot_rspec_file
      end

      def create_dot_rspec_file
        if File.exist?('.rspec')
          report_exists('.rspec')
        else
          report_creating('.rspec')
          File.open('.rspec','w') do |f|
            f.write File.read(File.expand_path("../project_initializer/dot_rspec", __FILE__))
          end
        end
      end

      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 File.read(File.expand_path("../project_initializer/spec_helper.rb", __FILE__))
          end
        end
      end

      def report_exists(file)
        puts "   exist   #{file}"
      end

      def report_creating(file)
        puts "  create   #{file}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-core-3.0.0.rc1 lib/rspec/core/project_initializer.rb