Top Level Namespace

Defined Under Namespace

Modules: Erubis, Kernel, Language, Merb Classes: Dictionary, Object, String

Instance Method Summary collapse

Instance Method Details

#install_homeObject



10
11
12
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 10

def install_home
  ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
end

#run_specs(globs, spec_cmd = 'spec', run_opts = "-c -f s") ⇒ Object

Runs specs in all files matching the file pattern.

Parameters

globs<String, Array>

File patterns to look for.

spec_cmd<~to_s>

The spec command. Defaults to “spec”.

run_opts<String>

Options to pass to spec commands, for instance, if you want to use profiling formatter.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/merb-core/test/run_specs.rb', line 12

def run_specs(globs, spec_cmd='spec', run_opts = "-c -f s")
  require "optparse"
  require "spec"
  globs = globs.is_a?(Array) ? globs : [globs]
  examples, failures, errors, pending = 0, 0, 0, 0

  time = Benchmark.measure do
    globs.each do |glob|
      Dir[glob].each do |spec|
        response = Open3.popen3("#{spec_cmd} #{File.expand_path(spec)} #{run_opts}") do |i,o,e|
          while out = o.gets
            STDOUT.puts out
            STDOUT.flush
            if out =~ /\d+ example/
              e, f, p = out.match(/(\d+) examples?, (\d+) failures?(?:, (\d+) pending?)?/)[1..-1]
              examples += e.to_i; failures += f.to_i; pending += p.to_i
            end
          end
          errors += 1 if e.is_a?(IO)
          STDOUT.puts e.read if e.is_a?(IO)
        end
      end
    end
  end

  puts
  puts "*** TOTALS ***"
  if failures == 0
    print "\e[32m"
  else
    print "\e[31m"
  end
  puts "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending, #{sprintf("suite run in %3.3f seconds", time.real)}"
  # TODO: we need to report pending examples all together
  print "\e[0m"
end

#sudoObject



1
2
3
4
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 1

def sudo
  ENV['MERB_SUDO'] ||= "sudo"
  sudo = windows? ? "" : ENV['MERB_SUDO']
end

#windows?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 6

def windows?
  (PLATFORM =~ /win32|cygwin/) rescue nil
end