summaryrefslogtreecommitdiff
path: root/spec/ruby/core/thread/start_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/thread/start_spec.rb')
-rw-r--r--spec/ruby/core/thread/start_spec.rb44
1 files changed, 39 insertions, 5 deletions
diff --git a/spec/ruby/core/thread/start_spec.rb b/spec/ruby/core/thread/start_spec.rb
index 932e782382..a2ee52180b 100644
--- a/spec/ruby/core/thread/start_spec.rb
+++ b/spec/ruby/core/thread/start_spec.rb
@@ -1,9 +1,43 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
-require File.expand_path('../shared/start', __FILE__)
+require_relative '../../spec_helper'
describe "Thread.start" do
- describe "Thread.start" do
- it_behaves_like :thread_start, :start
+ before :each do
+ ScratchPad.clear
+ end
+
+ it "raises an ArgumentError if not passed a block" do
+ -> {
+ Thread.start
+ }.should.raise(ArgumentError)
+ end
+
+ it "spawns a new Thread running the block" do
+ run = false
+ t = Thread.start { run = true }
+ t.should.is_a?(Thread)
+ t.join
+
+ run.should == true
+ end
+
+ it "respects Thread subclasses" do
+ c = Class.new(Thread)
+ t = c.start { }
+ t.should.is_a?(c)
+
+ t.join
+ end
+
+ it "does not call #initialize" do
+ c = Class.new(Thread) do
+ def initialize
+ ScratchPad.record :bad
+ end
+ end
+
+ t = c.start { }
+ t.join
+
+ ScratchPad.recorded.should == nil
end
end