Parent

Class/Module Index [+]

Quicksearch

Object

Public Instance Methods

assigns(attr) click to toggle source

Parameters

attr<~to_s>

The name of the instance variable to get.

Returns

Object

The instance variable @attr for this object.

Examples

# In a spec
@my_obj.assigns(:my_value).should == @my_value
# File lib/merb-core/test/test_ext/object.rb, line 11
def assigns(attr)
  self.instance_variable_get("@#{attr}")
end
run_spec(spec, base_dir, run_opts = "-fs") click to toggle source
# File lib/merb-core/test/run_spec.rb, line 22
def run_spec(spec, base_dir, run_opts = "-fs")

  $VERBOSE = nil
  err, out = StringIO.new, StringIO.new
  def out.tty?() true end
  options = Spec::Runner::OptionParser.parse(%(#{spec} --color).concat(%(#{run_opts})), err, out)
  options.filename_pattern = File.expand_path(spec)
  failure = ! Spec::Runner::CommandLine.run(options)
  File.open(base_dir / "results" / "#{File.basename(spec)}_out", "w") do |file|
    file.puts out.string
  end
  File.open(base_dir / "results" / "#{File.basename(spec)}_err", "w") do |file|
    file.puts err.string
  end
  exit!(failure ? -1 : 0)
end
run_specs(globs, spec_cmd='spec', run_opts = "-c", except = []) click to toggle source

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.

except>

File paths to skip.

# File lib/merb-core/test/run_specs.rb, line 86
def run_specs(globs, spec_cmd='spec', run_opts = "-c", except = [])
  require "optparse"
  require "spec"
  globs = globs.is_a?(Array) ? globs : [globs]
  
  forking = (ENV["FORK"] ? ENV["FORK"] == "1" : Merb.forking_environment?)
  base_dir = File.expand_path(File.dirname(__FILE__) / ".." / ".." / "..")
  
  counter = Merb::Counter.new
  forks   = 0
  failure = false

  FileUtils.rm_rf(base_dir / "results")
  FileUtils.mkdir_p(base_dir / "results")

  time = Benchmark.measure do
    files = {}
    globs.each do |glob|
      Dir[glob].each do |spec|
        if forking
          Kernel.fork do
            run_spec(spec, base_dir, run_opts)
          end
          Process.wait
        else
          `NOW=1 #{Gem.ruby} #{File.dirname(__FILE__) / "run_spec.rb"} \"#{spec}\"`
        end
        begin
          out = File.read(base_dir / "results" / "#{File.basename(spec)}_out")
          err = File.read(base_dir / "results" / "#{File.basename(spec)}_err")
          counter.add(spec, out, err)        
        rescue Errno::ENOENT => e
          STDOUT.puts e.message
        end
      end
    end
  end
  
  Process.waitall
  
  counter.time = time
  counter.report
  FileUtils.rm_rf(base_dir / "results")  
  exit!(counter.failed? ? -1 : 0)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.