Sha256: 2fb28781223363480f510abda1a13a2ab9ff3f360d20541377417d04dcfb769f

Contents?: true

Size: 1.04 KB

Versions: 68

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Spork::Forker do
  describe ".new" do
    it "runs a block in a fork" do
      $var = "hello world"
      Spork::Forker.new { $var = "booyah" }.result
      $var.should == "hello world"
    end
  end
  
  describe "#result" do
    it "returns the result" do
      Spork::Forker.new { "results" }.result.should == "results"
    end
  end
  
  describe "#running?" do
    it "reports when the fork is running" do
      forker = Spork::Forker.new { sleep 0.1 }
      forker.running?.should == true
      forker.result
      sleep 0.1
      forker.running?.should == false
    end
  end
  
  describe "#abort" do
    it "aborts a fork and returns nil for the result" do
      started_at = Time.now
      ended_at = nil
      forker = Spork::Forker.new { sleep 5 }
      Thread.new do
        forker.result.should == nil
        ended_at = Time.now
      end
      sleep 0.5
      forker.abort
      sleep 0.1
      (ended_at - started_at).should be_within(0.1).of(0.5)
      forker.running?.should == false
    end
  end
end unless windows?

Version data entries

68 entries across 68 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.7.4 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.7.3 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.7.2 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.7.1 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.7.0 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.9 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.8 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.7 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.6 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.5 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.4 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.3 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.2 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.1 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.6.0 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.5.17 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.5.16 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.5.15 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb
classiccms-0.5.14 vendor/bundle/gems/spork-0.9.0/spec/spork/forker_spec.rb