Sha256: 0fc51fd0eb967c4006612e8fb38f10b81645ef8af32a87bea5b0e49a8c1570c9

Contents?: true

Size: 1.52 KB

Versions: 27

Compression:

Stored size: 1.52 KB

Contents

module RSpec
  module Core
    class CommandLineConfiguration
      attr_reader :command

      def initialize(cmd)
        @command = cmd
      end

      def run
        case @command
        when 'autotest' then Autotest.generate
        else raise ArgumentError, <<-MESSAGE

#{"*"*50}
"#{@command}" is not valid a valid argument to "rspec --configure".
Supported options are:

  rspec --configure autotest # generates .rspec file

#{"*"*50}
MESSAGE
        end
      end

      class Autotest
        class << self
          def generate
            create_dot_rspec_file
            remove_autotest_dir_if_present
          end

          def create_dot_rspec_file
            puts "Autotest loads RSpec's Autotest subclass when there is a .rspec file in the project's root directory."
            if File.exist?('./.rspec')
              puts ".rspec file already exists, so nothing was changed."
            else
              FileUtils.touch('./.rspec')
              puts ".rspec file did not exist, so it was created."
            end
          end

          def remove_autotest_dir_if_present
            if discover_file_exists?
              print "Delete obsolete autotest/discover.rb [y/n]? "
              exit if gets !~ /y/i
              FileUtils.rm_rf(discover_file_path)
            end
          end

          def discover_file_exists?
            File.exist?(discover_file_path)
          end

          def discover_file_path
            File.join('autotest', 'discover.rb')
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
horseman-0.0.4 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
horseman-0.0.3 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
horseman-0.0.2 vendor/ruby/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.6.alpha vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.5 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.4 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.3 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.2 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
nutshell-crm-0.0.1 vendor/bundle/gems/rspec-core-2.7.1/lib/rspec/core/command_line_configuration.rb
rspec-core-2.8.0.rc1 lib/rspec/core/command_line_configuration.rb
rspec-core-2.7.1 lib/rspec/core/command_line_configuration.rb
rspec-core-2.7.0 lib/rspec/core/command_line_configuration.rb
rspec-core-2.7.0.rc1 lib/rspec/core/command_line_configuration.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/command_line_configuration.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-core-2.5.1/lib/rspec/core/command_line_configuration.rb
rspec-core-2.6.4 lib/rspec/core/command_line_configuration.rb
rspec-core-2.6.3 lib/rspec/core/command_line_configuration.rb
rspec-core-2.6.3.beta1 lib/rspec/core/command_line_configuration.rb
rspec-core-2.6.2.rc lib/rspec/core/command_line_configuration.rb
rspec-core-2.6.0 lib/rspec/core/command_line_configuration.rb