summaryrefslogtreecommitdiff
path: root/spec/ruby/core/thread/priority_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/thread/priority_spec.rb')
-rw-r--r--spec/ruby/core/thread/priority_spec.rb32
1 files changed, 18 insertions, 14 deletions
diff --git a/spec/ruby/core/thread/priority_spec.rb b/spec/ruby/core/thread/priority_spec.rb
index b986fb7a0d..970f7f9971 100644
--- a/spec/ruby/core/thread/priority_spec.rb
+++ b/spec/ruby/core/thread/priority_spec.rb
@@ -1,42 +1,45 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
describe "Thread#priority" do
- before do
+ before :each do
@current_priority = Thread.current.priority
ThreadSpecs.clear_state
@thread = Thread.new { Thread.pass until ThreadSpecs.state == :exit }
+ Thread.pass until @thread.alive?
end
- after do
+ after :each do
ThreadSpecs.state = :exit
@thread.join
end
it "inherits the priority of the current thread while running" do
- @thread.alive?.should be_true
+ @thread.alive?.should == true
@thread.priority.should == @current_priority
end
it "maintain the priority of the current thread after death" do
ThreadSpecs.state = :exit
@thread.join
- @thread.alive?.should be_false
+ @thread.alive?.should == false
@thread.priority.should == @current_priority
end
it "returns an integer" do
- @thread.priority.should be_kind_of(Integer)
+ @thread.priority.should.is_a?(Integer)
end
end
describe "Thread#priority=" do
- before do
+ before :each do
ThreadSpecs.clear_state
- @thread = Thread.new {}
+ @thread = Thread.new { Thread.pass until ThreadSpecs.state == :exit }
+ Thread.pass until @thread.alive?
end
- after do
+ after :each do
+ ThreadSpecs.state = :exit
@thread.join
end
@@ -56,13 +59,14 @@ describe "Thread#priority=" do
describe "when set with a non-integer" do
it "raises a type error" do
- lambda{ @thread.priority = Object.new }.should raise_error(TypeError)
+ ->{ @thread.priority = Object.new }.should.raise(TypeError)
end
end
it "sets priority even when the thread has died" do
- @thread.join
- @thread.priority = 3
- @thread.priority.should == 3
+ thread = Thread.new {}
+ thread.join
+ thread.priority = 3
+ thread.priority.should == 3
end
end