Flowdock
define(# :nodoc:) public

No documentation

This method has no description. You can help the RSpec community by adding new notes.

Hide source
# File lib/spec/rake/spectask.rb, line 144
      def define # :nodoc:
        spec_script = File.expand_path(File.dirname(__FILE__) + '/../../../bin/spec')

        lib_path = libs.join(File::PATH_SEPARATOR)
        actual_name = Hash === name ? name.keys.first : name
        unless ::Rake.application.last_comment
          desc "Run specs" + (rcov ? " using RCov" : "")
        end
        task name do
          RakeFileUtils.verbose(verbose) do
            unless spec_file_list.empty?
              # ruby [ruby_opts] -Ilib -S rcov [rcov_opts] bin/spec -- examples [spec_opts]
              # or
              # ruby [ruby_opts] -Ilib bin/spec examples [spec_opts]
              cmd = "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} "

              rb_opts = ruby_opts.clone
              rb_opts << "-I\"#{lib_path}\""
              rb_opts << "-S rcov" if rcov
              rb_opts << "-w" if warning
              cmd << rb_opts.join(" ")
              cmd << " "
              cmd << rcov_option_list
              cmd << %[ -o "#{rcov_dir}" ] if rcov
              cmd << %Q|"#{spec_script}"|
              cmd << " "
              cmd << "-- " if rcov
              cmd << spec_file_list.collect { |fn| %["#{fn}"] }.join(' ')
              cmd << " "
              cmd << spec_option_list
              if out
                cmd << " "
                cmd << %Q| > "#{out}"|
                STDERR.puts "The Spec::Rake::SpecTask#out attribute is DEPRECATED and will be removed in a future version. Use --format FORMAT:WHERE instead."
              end
              if verbose
                puts cmd
              end
              unless system(cmd)
                STDERR.puts failure_message if failure_message
                raise("Command #{cmd} failed") if fail_on_error
              end
            end
          end
        end

        if rcov
          desc "Remove rcov products for #{actual_name}"
          task paste("clobber_", actual_name) do
            rm_r rcov_dir rescue nil
          end

          clobber_task = paste("clobber_", actual_name)
          task :clobber => [clobber_task]

          task actual_name => clobber_task
        end
        self
      end
Register or log in to add new notes.