Skip to content

Commit f4204a6

Browse files
committed
Merge pull request #128 from ruby-concurrency/refactor/rspec3
Upgrade to RSpec 3.0
2 parents 73be654 + ddb29e2 commit f4204a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1204
-1182
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ group :development do
88
end
99

1010
group :testing do
11-
gem 'rspec', '~> 2.14.1'
11+
gem 'rspec', '~> 3.0.0'
1212
gem 'simplecov', '~> 0.8.2', :require => false
1313
gem 'coveralls', '~> 0.7.0', :require => false
1414
gem 'timecop', '~> 0.7.1'

spec/concurrent/actress_spec.rb

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ def on_message(message)
6767
actor = Ping.spawn :ping, queue
6868

6969
# when spawn returns children are set
70-
Concurrent::Actress.root.send(:core).instance_variable_get(:@children).should include(actor)
70+
expect(Concurrent::Actress.root.send(:core).instance_variable_get(:@children)).to include(actor)
7171

7272
actor << 'a' << 1
73-
queue.pop.should eq 'a'
74-
actor.ask(2).value.should eq 2
73+
expect(queue.pop).to eq 'a'
74+
expect(actor.ask(2).value).to eq 2
7575

76-
actor.parent.should eq Concurrent::Actress.root
77-
Concurrent::Actress.root.path.should eq '/'
78-
actor.path.should eq '/ping'
76+
expect(actor.parent).to eq Concurrent::Actress.root
77+
expect(Concurrent::Actress.root.path).to eq '/'
78+
expect(actor.path).to eq '/ping'
7979
child = actor.ask(:child).value
80-
child.path.should eq '/ping/pong'
80+
expect(child.path).to eq '/ping/pong'
8181
queue.clear
8282
child.ask(3)
83-
queue.pop.should eq 3
83+
expect(queue.pop).to eq 3
8484

8585
actor << :terminate
86-
actor.ask(:blow_up).wait.should be_rejected
86+
expect(actor.ask(:blow_up).wait).to be_rejected
8787
terminate_actors actor, child
8888
end
8989
end
@@ -102,24 +102,40 @@ def on_message(message)
102102

103103
subjects.each do |desc, subject_definition|
104104
describe desc do
105-
subject &subject_definition
106-
after { terminate_actors subject }
107-
its(:path) { should eq '/ping' }
108-
its(:parent) { pending('intermittent JRuby deadlock'); should eq Actress.root }
109-
its(:name) { should eq 'ping' }
110-
it('executor should be global') { subject.executor.should eq Concurrent.configuration.global_task_pool }
111-
its(:reference) { should eq subject }
105+
subject(:actor, &subject_definition)
106+
after { terminate_actors actor }
107+
108+
describe '#path' do
109+
subject { super().path }
110+
it { is_expected.to eq '/ping' }
111+
end
112+
113+
describe '#parent' do
114+
subject { super().parent }
115+
it { is_expected.to eq Actress.root }
116+
end
117+
118+
describe '#name' do
119+
subject { super().name }
120+
it { is_expected.to eq 'ping' }
121+
end
122+
it('executor should be global') { expect(subject.executor).to eq Concurrent.configuration.global_task_pool }
123+
124+
describe '#reference' do
125+
subject { super().reference }
126+
it { is_expected.to eq subject }
127+
end
112128
it 'returns arg' do
113-
subject.ask!(:anything).should eq 'arg'
129+
expect(subject.ask!(:anything)).to eq 'arg'
114130
end
115131
end
116132
end
117133
end
118134

119135
it 'terminates on failed initialization' do
120136
a = AdHoc.spawn(name: :fail, logger: Concurrent.configuration.no_logger) { raise }
121-
a.ask(nil).wait.rejected?.should be_true
122-
a.terminated?.should be_true
137+
expect(a.ask(nil).wait.rejected?).to be_truthy
138+
expect(a.terminated?).to be_truthy
123139
end
124140

125141
it 'terminates on failed initialization and raises with spawn!' do
@@ -130,8 +146,8 @@ def on_message(message)
130146

131147
it 'terminates on failed message processing' do
132148
a = AdHoc.spawn(name: :fail, logger: Concurrent.configuration.no_logger) { -> _ { raise } }
133-
a.ask(nil).wait.rejected?.should be_true
134-
a.terminated?.should be_true
149+
expect(a.ask(nil).wait.rejected?).to be_truthy
150+
expect(a.terminated?).to be_truthy
135151
end
136152
end
137153

@@ -140,7 +156,7 @@ def on_message(message)
140156
specify do
141157
subject.tell(1).tell(1)
142158
subject << 1 << 1
143-
subject.ask(0).value!.should eq 4
159+
expect(subject.ask(0).value!).to eq 4
144160
end
145161
after { terminate_actors subject }
146162
end
@@ -160,8 +176,8 @@ def on_message(message)
160176

161177
it 'has children set after a child is created' do
162178
child = parent.ask!(:child)
163-
parent.ask!(nil).should include(child)
164-
child.ask!(nil).should eq parent
179+
expect(parent.ask!(nil)).to include(child)
180+
expect(child.ask!(nil)).to eq parent
165181

166182
terminate_actors parent, child
167183
end
@@ -171,11 +187,11 @@ def on_message(message)
171187
subject { AdHoc.spawn(:subject) { -> _ { envelope } } }
172188
specify do
173189
envelope = subject.ask!('a')
174-
envelope.should be_a_kind_of Envelope
175-
envelope.message.should eq 'a'
176-
envelope.ivar.should be_completed
177-
envelope.ivar.value.should eq envelope
178-
envelope.sender.should eq Thread.current
190+
expect(envelope).to be_a_kind_of Envelope
191+
expect(envelope.message).to eq 'a'
192+
expect(envelope.ivar).to be_completed
193+
expect(envelope.ivar.value).to eq envelope
194+
expect(envelope.sender).to eq Thread.current
179195
terminate_actors subject
180196
end
181197
end
@@ -196,11 +212,11 @@ def on_message(message)
196212

197213
it 'terminates with all its children' do
198214
child = subject.ask! :child
199-
subject.terminated?.should be_false
215+
expect(subject.terminated?).to be_falsey
200216
subject.ask(:terminate).wait
201-
subject.terminated?.should be_true
217+
expect(subject.terminated?).to be_truthy
202218
child.terminated.wait
203-
child.terminated?.should be_true
219+
expect(child.terminated?).to be_truthy
204220

205221
terminate_actors subject, child
206222
end

0 commit comments

Comments
 (0)