Parent

Class 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
11:   def assigns(attr)
12:     self.instance_variable_get("@#{attr}")
13:   end
run_spec(spec, base_dir, run_opts = "-fs") click to toggle source
    # File lib/merb-core/test/run_spec.rb, line 22
22: def run_spec(spec, base_dir, run_opts = "-fs")
23: 
24:   $VERBOSE = nil
25:   err, out = StringIO.new, StringIO.new
26:   def out.tty?() true end
27:   options = Spec::Runner::OptionParser.parse(%(#{spec} --color).concat(%(#{run_opts})), err, out)
28:   options.filename_pattern = File.expand_path(spec)
29:   failure = ! Spec::Runner::CommandLine.run(options)
30:   File.open(base_dir / "results" / "#{File.basename(spec)}_out", "w") do |file|
31:     file.puts out.string
32:   end
33:   File.open(base_dir / "results" / "#{File.basename(spec)}_err", "w") do |file|
34:     file.puts err.string
35:   end
36:   exit!(failure ? 1 : 0)
37: 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[String]>

File patterns to look for.

spec_cmd<~to_s>

The spec command. Defaults to “spec”.

run_opts

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
 86: def run_specs(globs, spec_cmd='spec', run_opts = "-c", except = [])
 87:   require "optparse"
 88:   require "spec"
 89:   globs = globs.is_a?(Array) ? globs : [globs]
 90:   
 91:   forking = (ENV["FORK"] ? ENV["FORK"] == "1" : Merb.forking_environment?)
 92:   base_dir = File.expand_path(File.dirname(__FILE__) / ".." / ".." / "..")
 93:   
 94:   counter = Merb::Counter.new
 95:   forks   = 0
 96:   failure = false
 97: 
 98:   FileUtils.rm_rf(base_dir / "results")
 99:   FileUtils.mkdir_p(base_dir / "results")
100: 
101:   time = Benchmark.measure do
102:     files = {}
103:     globs.each do |glob|
104:       Dir[glob].each do |spec|
105:         if forking
106:           Kernel.fork do
107:             run_spec(spec, base_dir, run_opts)
108:           end
109:           Process.wait
110:         else
111:           `NOW=1 #{Gem.ruby} #{File.dirname(__FILE__) / "run_spec.rb"} \"#{spec}\"`
112:         end
113:         begin
114:           out = File.read(base_dir / "results" / "#{File.basename(spec)}_out")
115:           err = File.read(base_dir / "results" / "#{File.basename(spec)}_err")
116:           counter.add(spec, out, err)        
117:         rescue Errno::ENOENT => e
118:           STDOUT.puts e.message
119:         end
120:       end
121:     end
122:   end
123:   
124:   Process.waitall
125:   
126:   counter.time = time
127:   counter.report
128:   FileUtils.rm_rf(base_dir / "results")  
129:   exit!(counter.failed? ? 1 : 0)
130: end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.