ione 1.3.0.pre0 → 1.3.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,7 +90,7 @@ module Ione
90
90
  restarted_future.value
91
91
  await { sequence.size >= 2 }
92
92
  begin
93
- sequence.should == [:stopped, :restarted]
93
+ sequence.should eq([:stopped, :restarted])
94
94
  ensure
95
95
  reactor.stop
96
96
  barrier.push(nil) while reactor.running?
@@ -141,8 +141,6 @@ module Ione
141
141
 
142
142
  context 'when already started' do
143
143
  it 'is not started again' do
144
- calls = 0
145
- lock = Mutex.new
146
144
  ticks = Queue.new
147
145
  barrier = Queue.new
148
146
  selector.handler do
@@ -184,18 +182,17 @@ module Ione
184
182
  end
185
183
 
186
184
  it 'keeps running until stop completes' do
187
- running_barrier = Queue.new
188
- stop_barrier = Queue.new
185
+ barrier = Queue.new
189
186
  selector.handler do
190
- running_barrier.push(nil)
191
- stop_barrier.pop
187
+ barrier.pop
192
188
  [[], [], []]
193
189
  end
194
190
  reactor.start.value
195
191
  future = reactor.stop
196
- running_barrier.pop
192
+ barrier.push(nil)
197
193
  reactor.should be_running
198
- stop_barrier.push(nil) until future.completed?
194
+ barrier.push(nil) until future.completed?
195
+ reactor.should_not be_running
199
196
  end
200
197
 
201
198
  it 'unblocks the reactor' do
@@ -215,7 +212,7 @@ module Ione
215
212
  it 'drains all sockets' do
216
213
  reactor.start.value
217
214
  TCPServer.open(0) do |server|
218
- lazy_socket = Thread.start { server.accept }
215
+ Thread.start { server.accept }
219
216
  connection = reactor.connect(server.addr[3], server.addr[1], 5).value
220
217
  writable = false
221
218
  connection.stub(:stub_writable?) { writable }
@@ -251,7 +248,7 @@ module Ione
251
248
  end
252
249
  reactor.start.value
253
250
  TCPServer.open(0) do |server|
254
- lazy_socket = Thread.start { server.accept }
251
+ Thread.start { server.accept }
255
252
  connection = reactor.connect(server.addr[3], server.addr[1], 5).value
256
253
  stopped_future = nil
257
254
  mutex.synchronize do
@@ -358,7 +355,7 @@ module Ione
358
355
  reactor.on_error { |e| error = e }
359
356
  reactor.start
360
357
  await { error }
361
- error.message.should == 'Blurgh'
358
+ error.message.should eq('Blurgh')
362
359
  end
363
360
 
364
361
  it 'calls the listener immediately when the reactor has already crashed' do
@@ -389,16 +386,16 @@ module Ione
389
386
  await { !reactor.running? }
390
387
  await { calls.size >= 2 }
391
388
  reactor.on_error { calls << :pre_restarted }
392
- calls.should == [
389
+ calls.should eq([
393
390
  :pre_started,
394
391
  :post_started,
395
392
  :pre_restarted,
396
- ]
393
+ ])
397
394
  reactor.start
398
395
  reactor.on_error { calls << :post_restarted }
399
396
  barrier.push(nil)
400
397
  await { !reactor.running? }
401
- calls.should == [
398
+ calls.should eq([
402
399
  :pre_started,
403
400
  :post_started,
404
401
  :pre_restarted,
@@ -406,7 +403,7 @@ module Ione
406
403
  :post_started,
407
404
  :pre_restarted,
408
405
  :post_restarted,
409
- ]
406
+ ])
410
407
  end
411
408
  end
412
409
 
@@ -426,7 +423,7 @@ module Ione
426
423
  with_server do |host, port|
427
424
  reactor.start.value
428
425
  x = reactor.connect(host, port, 5) { :foo }.value
429
- x.should == :foo
426
+ x.should eq(:foo)
430
427
  end
431
428
  end
432
429
 
@@ -434,7 +431,7 @@ module Ione
434
431
  with_server do |host, port|
435
432
  reactor.start.value
436
433
  connection = reactor.connect(host, port).value
437
- connection.connection_timeout.should == 5
434
+ connection.connection_timeout.should eq(5)
438
435
  end
439
436
  end
440
437
 
@@ -442,7 +439,7 @@ module Ione
442
439
  with_server do |host, port|
443
440
  reactor.start.value
444
441
  connection = reactor.connect(host, port, timeout: 9).value
445
- connection.connection_timeout.should == 9
442
+ connection.connection_timeout.should eq(9)
446
443
  end
447
444
  end
448
445
 
@@ -519,19 +516,19 @@ module Ione
519
516
  it 'returns a future that resolves to what the given block returns' do
520
517
  reactor.start.value
521
518
  x = reactor.bind(ENV['SERVER_HOST'], port, 5) { |acceptor| :foo }.value
522
- x.should == :foo
519
+ x.should eq(:foo)
523
520
  end
524
521
 
525
522
  it 'defaults to a backlog of 5' do
526
523
  reactor.start.value
527
524
  acceptor = reactor.bind(ENV['SERVER_HOST'], port).value
528
- acceptor.backlog.should == 5
525
+ acceptor.backlog.should eq(5)
529
526
  end
530
527
 
531
528
  it 'takes the backlog from the :backlog option' do
532
529
  reactor.start.value
533
530
  acceptor = reactor.bind(ENV['SERVER_HOST'], port, backlog: 9).value
534
- acceptor.backlog.should == 9
531
+ acceptor.backlog.should eq(9)
535
532
  end
536
533
 
537
534
  it 'returns the acceptor when no block is given' do
@@ -584,10 +581,12 @@ module Ione
584
581
  end
585
582
 
586
583
  it 'returns a future that is resolved after the specified duration' do
584
+ start = Time.now
587
585
  clock.stub(:now).and_return(1)
588
- f = reactor.schedule_timer(0.1)
589
- clock.stub(:now).and_return(1.1)
586
+ f = reactor.schedule_timer(8)
587
+ clock.stub(:now).and_return(10.1)
590
588
  await { f.resolved? }
589
+ expect(Time.now - start).to be < 1
591
590
  end
592
591
  end
593
592
 
@@ -713,7 +712,11 @@ module Ione
713
712
 
714
713
  describe IoLoopBody do
715
714
  let :loop_body do
716
- described_class.new(selector: selector, clock: clock)
715
+ described_class.new(unblocker, selector: selector, clock: clock)
716
+ end
717
+
718
+ let :unblocker do
719
+ double(:unblocker, connected?: true, connecting?: false, writable?: false, closed?: false)
717
720
  end
718
721
 
719
722
  let :selector do
@@ -728,14 +731,24 @@ module Ione
728
731
  double(:socket, connected?: false, connecting?: false, writable?: false, closed?: false)
729
732
  end
730
733
 
734
+ before do
735
+ unblocker.stub(:close) { unblocker.stub(:closed?).and_return(true) }
736
+ end
737
+
731
738
  describe '#tick' do
732
739
  before do
733
740
  loop_body.add_socket(socket)
734
741
  end
735
742
 
743
+ it 'passes the unblocker to the selector as the first readable' do
744
+ socket.stub(:connected?).and_return(true)
745
+ selector.should_receive(:select).with([unblocker, socket], anything, anything, anything).and_return([nil, nil, nil])
746
+ loop_body.tick
747
+ end
748
+
736
749
  it 'passes connected sockets as readables to the selector' do
737
750
  socket.stub(:connected?).and_return(true)
738
- selector.should_receive(:select).with([socket], anything, anything, anything).and_return([nil, nil, nil])
751
+ selector.should_receive(:select).with([unblocker, socket], anything, anything, anything).and_return([nil, nil, nil])
739
752
  loop_body.tick
740
753
  end
741
754
 
@@ -748,7 +761,7 @@ module Ione
748
761
  it 'passes writable sockets as both readable and writable to the selector' do
749
762
  socket.stub(:connected?).and_return(true)
750
763
  socket.stub(:writable?).and_return(true)
751
- selector.should_receive(:select).with([socket], [socket], anything, anything).and_return([nil, nil, nil])
764
+ selector.should_receive(:select).with([unblocker, socket], [socket], anything, anything).and_return([nil, nil, nil])
752
765
  loop_body.tick
753
766
  end
754
767
 
@@ -761,7 +774,7 @@ module Ione
761
774
 
762
775
  it 'filters out closed sockets' do
763
776
  socket.stub(:closed?).and_return(true)
764
- selector.should_receive(:select).with([], [], anything, anything).and_return([nil, nil, nil])
777
+ selector.should_receive(:select).with([unblocker], [], anything, anything).and_return([nil, nil, nil])
765
778
  loop_body.tick
766
779
  end
767
780
 
@@ -805,7 +818,7 @@ module Ione
805
818
  end
806
819
 
807
820
  it 'allows the caller to specify a custom timeout' do
808
- loop_body = described_class.new(selector: selector, clock: clock, tick_resolution: 99)
821
+ loop_body = described_class.new(unblocker, selector: selector, clock: clock, tick_resolution: 99)
809
822
  selector.should_receive(:select).with(anything, anything, anything, 99).and_return([[], [], []])
810
823
  loop_body.tick
811
824
  end
@@ -900,4 +913,4 @@ module IoReactorSpec
900
913
  @body.call(*args)
901
914
  end
902
915
  end
903
- end
916
+ end
@@ -7,7 +7,7 @@ module Ione
7
7
  module Io
8
8
  describe SslAcceptor do
9
9
  let :acceptor do
10
- described_class.new('example.com', 4321, backlog = 3, unblocker, reactor, ssl_context, socket_impl, ssl_socket_impl)
10
+ described_class.new('example.com', 4321, 3, unblocker, reactor, ssl_context, socket_impl, ssl_socket_impl)
11
11
  end
12
12
 
13
13
  let :unblocker do
@@ -80,8 +80,8 @@ module Ione
80
80
  acceptor.bind
81
81
  acceptor.read
82
82
  accepted_handlers.should have(1).item
83
- accepted_handlers.first.host.should == 'example.com'
84
- accepted_handlers.first.port.should == 3333
83
+ accepted_handlers.first.host.should eq('example.com')
84
+ accepted_handlers.first.port.should eq(3333)
85
85
  end
86
86
 
87
87
  it 'returns the raw socket from #to_io' do
@@ -124,7 +124,7 @@ module Ione
124
124
  end
125
125
  handler.connect
126
126
  handler.read
127
- read_sizes.drop(1).should == [read_sizes.first] * 3
127
+ read_sizes.drop(1).should eq([read_sizes.first] * 3)
128
128
  end
129
129
  else
130
130
  it 'reads and initial chunk of data' do
@@ -134,7 +134,7 @@ module Ione
134
134
  ssl_socket.stub(:read_nonblock).and_return('fooo')
135
135
  handler.connect
136
136
  handler.read
137
- data.should == ['fooo']
137
+ data.should eq(['fooo'])
138
138
  end
139
139
 
140
140
  it 'reads once, and then again with the value of #pending, until #pending returns zero' do
@@ -149,7 +149,7 @@ module Ione
149
149
  end
150
150
  handler.connect
151
151
  handler.read
152
- read_sizes.drop(1).should == [3, 2, 1]
152
+ read_sizes.drop(1).should eq([3, 2, 1])
153
153
  end
154
154
  end
155
155
 
data/spec/spec_helper.rb CHANGED
@@ -24,4 +24,8 @@ unless ENV['COVERAGE'] == 'no' || RUBY_ENGINE == 'rbx'
24
24
  end
25
25
  end
26
26
 
27
+ RSpec.configure do |config|
28
+ config.warnings = true
29
+ end
30
+
27
31
  require 'ione'
@@ -11,6 +11,7 @@ class FakeServer
11
11
  @disconnects = 0
12
12
  @connections = []
13
13
  @received_bytes = ''
14
+ @running = false
14
15
  end
15
16
 
16
17
  def start(options={})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ione
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0.pre0
4
+ version: 1.3.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-12 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Reactive programming framework for Ruby, painless evented IO, futures
14
14
  and an efficient byte buffer
@@ -53,7 +53,7 @@ files:
53
53
  - spec/support/server_helper.rb
54
54
  homepage: http://github.com/iconara/ione
55
55
  licenses:
56
- - Apache License 2.0
56
+ - Apache-2.0
57
57
  metadata: {}
58
58
  post_install_message:
59
59
  rdoc_options: []
@@ -70,27 +70,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: 1.3.1
72
72
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.2.2
73
+ rubygems_version: 3.0.3
75
74
  signing_key:
76
75
  specification_version: 4
77
76
  summary: Reactive programming framework for Ruby
78
77
  test_files:
79
- - spec/integration/io_spec.rb
80
- - spec/integration/ssl_spec.rb
81
- - spec/ione/byte_buffer_spec.rb
82
- - spec/ione/future_spec.rb
83
- - spec/ione/heap_spec.rb
78
+ - spec/spec_helper.rb
79
+ - spec/ione/io/ssl_acceptor_spec.rb
80
+ - spec/ione/io/server_connection_spec.rb
81
+ - spec/ione/io/ssl_server_connection_spec.rb
84
82
  - spec/ione/io/acceptor_spec.rb
85
- - spec/ione/io/connection_common.rb
86
83
  - spec/ione/io/connection_spec.rb
87
- - spec/ione/io/io_reactor_spec.rb
88
- - spec/ione/io/server_connection_spec.rb
89
- - spec/ione/io/ssl_acceptor_spec.rb
90
84
  - spec/ione/io/ssl_connection_spec.rb
91
- - spec/ione/io/ssl_server_connection_spec.rb
92
- - spec/spec_helper.rb
85
+ - spec/ione/io/io_reactor_spec.rb
86
+ - spec/ione/io/connection_common.rb
87
+ - spec/ione/heap_spec.rb
88
+ - spec/ione/byte_buffer_spec.rb
89
+ - spec/ione/future_spec.rb
90
+ - spec/integration/ssl_spec.rb
91
+ - spec/integration/io_spec.rb
92
+ - spec/support/server_helper.rb
93
93
  - spec/support/await_helper.rb
94
94
  - spec/support/fake_server.rb
95
- - spec/support/server_helper.rb
96
- has_rdoc: