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.rb42
1 files changed, 38 insertions, 4 deletions
diff --git a/spec/ruby/core/thread/start_spec.rb b/spec/ruby/core/thread/start_spec.rb
index 3dd040f98b..a2ee52180b 100644
--- a/spec/ruby/core/thread/start_spec.rb
+++ b/spec/ruby/core/thread/start_spec.rb
@@ -1,9 +1,43 @@
require_relative '../../spec_helper'
-require_relative 'fixtures/classes'
-require_relative 'shared/start'
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