Class: LikeAVirgin::World

Inherits:
Object
  • Object
show all
Defined in:
lib/like_a_virgin/world.rb

Class Method Summary collapse

Class Method Details

.emit(files) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/like_a_virgin/world.rb', line 10

def self.emit(files)
  number, world = @cycle.next
  world.try :join

  stream = $stdout
  pid = fork do
    $stdout = stream
    $stderr = stream
    LikeAVirgin.stop
    ENV["TEST_ENV_NUMBER"] = number.to_s || ""
    ActiveRecord::Base.configurations = Rails.configuration.database_configuration
    ActiveRecord::Base.establish_connection

    ARGV.clear
    ARGV.push files.shift while !files.empty?
    ARGV.push "-O"
    ARGV.push "spec/spec.opts"

    require "spec/spec_helper"
    Spec::Runner.run
    exit
  end
  exit 1 if pid.nil?

  @worlds[number] = Thread.new { Process.waitpid pid }
end

.init(options) ⇒ Object



3
4
5
6
7
8
# File 'lib/like_a_virgin/world.rb', line 3

def self.init(options)
  @count  = options.count
  @worlds = {}
  @count.times{ |i| @worlds[i] = nil }
  @cycle  = @worlds.cycle
end