ione 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/ione/future.rb +5 -3
 - data/lib/ione/io/acceptor.rb +1 -0
 - data/lib/ione/io/base_connection.rb +2 -0
 - data/lib/ione/io/connection.rb +1 -0
 - data/lib/ione/io/io_reactor.rb +5 -4
 - data/lib/ione/io/ssl_connection.rb +1 -0
 - data/lib/ione/version.rb +1 -1
 - data/spec/integration/io_spec.rb +3 -3
 - data/spec/integration/ssl_spec.rb +7 -2
 - data/spec/ione/byte_buffer_spec.rb +38 -38
 - data/spec/ione/future_spec.rb +64 -65
 - data/spec/ione/heap_spec.rb +18 -18
 - data/spec/ione/io/acceptor_spec.rb +5 -5
 - data/spec/ione/io/connection_common.rb +2 -2
 - data/spec/ione/io/io_reactor_spec.rb +12 -14
 - data/spec/ione/io/ssl_acceptor_spec.rb +3 -3
 - data/spec/ione/io/ssl_connection_spec.rb +3 -3
 - data/spec/spec_helper.rb +4 -0
 - data/spec/support/fake_server.rb +1 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 443070cc0eb7a65e30942699de1c6435af5b07e1
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 50d81a6204f39103bcfbdadfdf4b5a764207ecf3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 596feb59ad89022c6ef6150b3cd5fc6903965108a4f7c219f2fdef612c3e83f76ed7750516c6381b29c8bfea7ae987301859b17a62339f43abf79ed223cf1810
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1cae4a2e82976c0d5eda3ba67fd2bb59ef6bb5853ab645bdccc1e268587cab1a24cc7eca42aa076ac2b0bb4737a33c6a6590916c3dc3b83e2b51b28e3178bc38
         
     | 
    
        data/lib/ione/future.rb
    CHANGED
    
    | 
         @@ -599,6 +599,8 @@ module Ione 
     | 
|
| 
       599 
599 
     | 
    
         
             
                  @lock = Mutex.new
         
     | 
| 
       600 
600 
     | 
    
         
             
                  @state = PENDING_STATE
         
     | 
| 
       601 
601 
     | 
    
         
             
                  @listeners = []
         
     | 
| 
      
 602 
     | 
    
         
            +
                  @value = nil
         
     | 
| 
      
 603 
     | 
    
         
            +
                  @error = nil
         
     | 
| 
       602 
604 
     | 
    
         
             
                end
         
     | 
| 
       603 
605 
     | 
    
         | 
| 
       604 
606 
     | 
    
         
             
                # Registers a listener that will be called when this future completes,
         
     | 
| 
         @@ -859,9 +861,9 @@ module Ione 
     | 
|
| 
       859 
861 
     | 
    
         
             
                    looping = more = true
         
     | 
| 
       860 
862 
     | 
    
         
             
                    while more
         
     | 
| 
       861 
863 
     | 
    
         
             
                      more = false
         
     | 
| 
       862 
     | 
    
         
            -
                      @futures.pop.on_complete do | 
     | 
| 
       863 
     | 
    
         
            -
                        if  
     | 
| 
       864 
     | 
    
         
            -
                          await_next( 
     | 
| 
      
 864 
     | 
    
         
            +
                      @futures.pop.on_complete do |value, error|
         
     | 
| 
      
 865 
     | 
    
         
            +
                        if error || @futures.empty? || !looping || !Thread.current.equal?(outer)
         
     | 
| 
      
 866 
     | 
    
         
            +
                          await_next(value, error)
         
     | 
| 
       865 
867 
     | 
    
         
             
                        else
         
     | 
| 
       866 
868 
     | 
    
         
             
                          more = true
         
     | 
| 
       867 
869 
     | 
    
         
             
                        end
         
     | 
    
        data/lib/ione/io/acceptor.rb
    CHANGED
    
    
| 
         @@ -15,10 +15,12 @@ module Ione 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  def initialize(host, port, unblocker)
         
     | 
| 
       16 
16 
     | 
    
         
             
                    @host = host
         
     | 
| 
       17 
17 
     | 
    
         
             
                    @port = port
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @io = nil
         
     | 
| 
       18 
19 
     | 
    
         
             
                    @unblocker = unblocker
         
     | 
| 
       19 
20 
     | 
    
         
             
                    @state = CONNECTING_STATE
         
     | 
| 
       20 
21 
     | 
    
         
             
                    @writable = false
         
     | 
| 
       21 
22 
     | 
    
         
             
                    @lock = Mutex.new
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @data_listener = nil
         
     | 
| 
       22 
24 
     | 
    
         
             
                    @write_buffer = ByteBuffer.new
         
     | 
| 
       23 
25 
     | 
    
         
             
                    @closed_promise = Promise.new
         
     | 
| 
       24 
26 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/ione/io/connection.rb
    CHANGED
    
    
    
        data/lib/ione/io/io_reactor.rb
    CHANGED
    
    | 
         @@ -95,6 +95,7 @@ module Ione 
     | 
|
| 
       95 
95 
     | 
    
         
             
                    @clock = options[:clock] || Time
         
     | 
| 
       96 
96 
     | 
    
         
             
                    @state = PENDING_STATE
         
     | 
| 
       97 
97 
     | 
    
         
             
                    @error_listeners = []
         
     | 
| 
      
 98 
     | 
    
         
            +
                    @unblocker = nil
         
     | 
| 
       98 
99 
     | 
    
         
             
                    @io_loop = IoLoopBody.new(@options)
         
     | 
| 
       99 
100 
     | 
    
         
             
                    @scheduler = Scheduler.new
         
     | 
| 
       100 
101 
     | 
    
         
             
                    @lock = Mutex.new
         
     | 
| 
         @@ -570,8 +571,8 @@ module Ione 
     | 
|
| 
       570 
571 
     | 
    
         
             
                    ensure
         
     | 
| 
       571 
572 
     | 
    
         
             
                      @lock.unlock
         
     | 
| 
       572 
573 
     | 
    
         
             
                    end
         
     | 
| 
       573 
     | 
    
         
            -
                    timers.each do | 
     | 
| 
       574 
     | 
    
         
            -
                       
     | 
| 
      
 574 
     | 
    
         
            +
                    timers.each do |t|
         
     | 
| 
      
 575 
     | 
    
         
            +
                      t.fail(CancelledError.new)
         
     | 
| 
       575 
576 
     | 
    
         
             
                    end
         
     | 
| 
       576 
577 
     | 
    
         
             
                    nil
         
     | 
| 
       577 
578 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -592,8 +593,8 @@ module Ione 
     | 
|
| 
       592 
593 
     | 
    
         
             
                        ensure
         
     | 
| 
       593 
594 
     | 
    
         
             
                          @lock.unlock
         
     | 
| 
       594 
595 
     | 
    
         
             
                        end
         
     | 
| 
       595 
     | 
    
         
            -
                        expired_timers.each do | 
     | 
| 
       596 
     | 
    
         
            -
                           
     | 
| 
      
 596 
     | 
    
         
            +
                        expired_timers.each do |t|
         
     | 
| 
      
 597 
     | 
    
         
            +
                          t.fulfill
         
     | 
| 
       597 
598 
     | 
    
         
             
                        end
         
     | 
| 
       598 
599 
     | 
    
         
             
                      end
         
     | 
| 
       599 
600 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/ione/version.rb
    CHANGED
    
    
    
        data/spec/integration/io_spec.rb
    CHANGED
    
    | 
         @@ -37,7 +37,7 @@ describe 'An IO reactor' do 
     | 
|
| 
       37 
37 
     | 
    
         
             
                  fake_server.await_connects(1)
         
     | 
| 
       38 
38 
     | 
    
         
             
                  fake_server.broadcast('hello world')
         
     | 
| 
       39 
39 
     | 
    
         
             
                  await { protocol_handler.data.bytesize > 0 }
         
     | 
| 
       40 
     | 
    
         
            -
                  protocol_handler.data.should  
     | 
| 
      
 40 
     | 
    
         
            +
                  protocol_handler.data.should eq('hello world')
         
     | 
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                it 'receives data on multiple connections' do
         
     | 
| 
         @@ -45,7 +45,7 @@ describe 'An IO reactor' do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                  fake_server.await_connects(10)
         
     | 
| 
       46 
46 
     | 
    
         
             
                  fake_server.broadcast('hello world')
         
     | 
| 
       47 
47 
     | 
    
         
             
                  await { protocol_handlers.all? { |c| c.data.bytesize > 0 } }
         
     | 
| 
       48 
     | 
    
         
            -
                  protocol_handlers.sample.data.should  
     | 
| 
      
 48 
     | 
    
         
            +
                  protocol_handlers.sample.data.should eq('hello world')
         
     | 
| 
       49 
49 
     | 
    
         
             
                end
         
     | 
| 
       50 
50 
     | 
    
         
             
              end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
         @@ -81,7 +81,7 @@ describe 'An IO reactor' do 
     | 
|
| 
       81 
81 
     | 
    
         
             
                  socket = TCPSocket.new(ENV['SERVER_HOST'], port)
         
     | 
| 
       82 
82 
     | 
    
         
             
                  socket.puts('HELLO')
         
     | 
| 
       83 
83 
     | 
    
         
             
                  result = socket.read(5)
         
     | 
| 
       84 
     | 
    
         
            -
                  result.should  
     | 
| 
      
 84 
     | 
    
         
            +
                  result.should eq('HELLO')
         
     | 
| 
       85 
85 
     | 
    
         
             
                  socket.close
         
     | 
| 
       86 
86 
     | 
    
         
             
                end
         
     | 
| 
       87 
87 
     | 
    
         
             
              end
         
     | 
| 
         @@ -49,6 +49,7 @@ describe 'SSL' do 
     | 
|
| 
       49 
49 
     | 
    
         
             
                ssl_context = OpenSSL::SSL::SSLContext.new
         
     | 
| 
       50 
50 
     | 
    
         
             
                ssl_context.key = OpenSSL::PKey::RSA.new(ssl_key)
         
     | 
| 
       51 
51 
     | 
    
         
             
                ssl_context.cert = OpenSSL::X509::Certificate.new(ssl_cert)
         
     | 
| 
      
 52 
     | 
    
         
            +
                ssl_context.tmp_dh_callback = proc { SslSpec::DH_PARAMS }
         
     | 
| 
       52 
53 
     | 
    
         | 
| 
       53 
54 
     | 
    
         
             
                f = io_reactor.start
         
     | 
| 
       54 
55 
     | 
    
         
             
                f = f.flat_map do
         
     | 
| 
         @@ -80,8 +81,8 @@ describe 'SSL' do 
     | 
|
| 
       80 
81 
     | 
    
         
             
                end
         
     | 
| 
       81 
82 
     | 
    
         
             
                client.write('hello world')
         
     | 
| 
       82 
83 
     | 
    
         
             
                response_received.future.value
         
     | 
| 
       83 
     | 
    
         
            -
                server_received_data.to_s.should  
     | 
| 
       84 
     | 
    
         
            -
                client_received_data.to_s.should  
     | 
| 
      
 84 
     | 
    
         
            +
                server_received_data.to_s.should eq('hello world')
         
     | 
| 
      
 85 
     | 
    
         
            +
                client_received_data.to_s.should eq('dlrow olleh')
         
     | 
| 
       85 
86 
     | 
    
         
             
              end
         
     | 
| 
       86 
87 
     | 
    
         | 
| 
       87 
88 
     | 
    
         
             
              it 'fails to send a message when not using encryption' do
         
     | 
| 
         @@ -95,3 +96,7 @@ describe 'SSL' do 
     | 
|
| 
       95 
96 
     | 
    
         
             
                client.should be_closed
         
     | 
| 
       96 
97 
     | 
    
         
             
              end
         
     | 
| 
       97 
98 
     | 
    
         
             
            end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            module SslSpec
         
     | 
| 
      
 101 
     | 
    
         
            +
              DH_PARAMS = OpenSSL::PKey::DH.new(File.read(File.expand_path('../../resources/dh.pem', __FILE__)))
         
     | 
| 
      
 102 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -15,28 +15,28 @@ module Ione 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  it 'can be initialized with bytes' do
         
     | 
| 
       18 
     | 
    
         
            -
                    described_class.new('hello').length.should  
     | 
| 
      
 18 
     | 
    
         
            +
                    described_class.new('hello').length.should eq(5)
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                describe '#length/#size/#bytesize' do
         
     | 
| 
       23 
23 
     | 
    
         
             
                  it 'returns the number of bytes in the buffer' do
         
     | 
| 
       24 
24 
     | 
    
         
             
                    buffer << 'foo'
         
     | 
| 
       25 
     | 
    
         
            -
                    buffer.length.should  
     | 
| 
      
 25 
     | 
    
         
            +
                    buffer.length.should eq(3)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                  it 'is zero initially' do
         
     | 
| 
       29 
     | 
    
         
            -
                    buffer.length.should  
     | 
| 
      
 29 
     | 
    
         
            +
                    buffer.length.should eq(0)
         
     | 
| 
       30 
30 
     | 
    
         
             
                  end
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                  it 'is aliased as #size' do
         
     | 
| 
       33 
33 
     | 
    
         
             
                    buffer << 'foo'
         
     | 
| 
       34 
     | 
    
         
            -
                    buffer.size.should  
     | 
| 
      
 34 
     | 
    
         
            +
                    buffer.size.should eq(3)
         
     | 
| 
       35 
35 
     | 
    
         
             
                  end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                  it 'is aliased as #bytesize' do
         
     | 
| 
       38 
38 
     | 
    
         
             
                    buffer << 'foo'
         
     | 
| 
       39 
     | 
    
         
            -
                    buffer.bytesize.should  
     | 
| 
      
 39 
     | 
    
         
            +
                    buffer.bytesize.should eq(3)
         
     | 
| 
       40 
40 
     | 
    
         
             
                  end
         
     | 
| 
       41 
41 
     | 
    
         
             
                end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
         @@ -67,19 +67,19 @@ module Ione 
     | 
|
| 
       67 
67 
     | 
    
         
             
                  end
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                  it 'stores its bytes as binary' do
         
     | 
| 
       70 
     | 
    
         
            -
                    buffer.append('hällö').length.should  
     | 
| 
       71 
     | 
    
         
            -
                    buffer.to_s.encoding.should  
     | 
| 
      
 70 
     | 
    
         
            +
                    buffer.append('hällö').length.should eq(7)
         
     | 
| 
      
 71 
     | 
    
         
            +
                    buffer.to_s.encoding.should eq(::Encoding::BINARY)
         
     | 
| 
       72 
72 
     | 
    
         
             
                  end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
                  it 'handles appending with multibyte strings' do
         
     | 
| 
       75 
75 
     | 
    
         
             
                    buffer.append('hello')
         
     | 
| 
       76 
76 
     | 
    
         
             
                    buffer.append('würld')
         
     | 
| 
       77 
     | 
    
         
            -
                    buffer.to_s.should  
     | 
| 
      
 77 
     | 
    
         
            +
                    buffer.to_s.should eq('hellowürld'.force_encoding(::Encoding::BINARY))
         
     | 
| 
       78 
78 
     | 
    
         
             
                  end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
                  it 'handles appending with another byte buffer' do
         
     | 
| 
       81 
81 
     | 
    
         
             
                    buffer.append('hello ').append(ByteBuffer.new('world'))
         
     | 
| 
       82 
     | 
    
         
            -
                    buffer.to_s.should  
     | 
| 
      
 82 
     | 
    
         
            +
                    buffer.to_s.should eq('hello world')
         
     | 
| 
       83 
83 
     | 
    
         
             
                  end
         
     | 
| 
       84 
84 
     | 
    
         
             
                end
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
         @@ -105,7 +105,7 @@ module Ione 
     | 
|
| 
       105 
105 
     | 
    
         
             
                    b2 = described_class.new
         
     | 
| 
       106 
106 
     | 
    
         
             
                    b1.append('foo')
         
     | 
| 
       107 
107 
     | 
    
         
             
                    b2.append('foo')
         
     | 
| 
       108 
     | 
    
         
            -
                    b1.should  
     | 
| 
      
 108 
     | 
    
         
            +
                    b1.should eq(b2)
         
     | 
| 
       109 
109 
     | 
    
         
             
                  end
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
                  it 'is equal to another buffer when both are empty' do
         
     | 
| 
         @@ -121,7 +121,7 @@ module Ione 
     | 
|
| 
       121 
121 
     | 
    
         
             
                    b2 = described_class.new
         
     | 
| 
       122 
122 
     | 
    
         
             
                    b1.append('foo')
         
     | 
| 
       123 
123 
     | 
    
         
             
                    b2.append('foo')
         
     | 
| 
       124 
     | 
    
         
            -
                    b1.hash.should  
     | 
| 
      
 124 
     | 
    
         
            +
                    b1.hash.should eq(b2.hash)
         
     | 
| 
       125 
125 
     | 
    
         
             
                  end
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
127 
     | 
    
         
             
                  it 'is not equal to the hash code of another buffer with other contents' do
         
     | 
| 
         @@ -135,26 +135,26 @@ module Ione 
     | 
|
| 
       135 
135 
     | 
    
         
             
                  it 'is equal to the hash code of another buffer when both are empty' do
         
     | 
| 
       136 
136 
     | 
    
         
             
                    b1 = described_class.new
         
     | 
| 
       137 
137 
     | 
    
         
             
                    b2 = described_class.new
         
     | 
| 
       138 
     | 
    
         
            -
                    b1.hash.should  
     | 
| 
      
 138 
     | 
    
         
            +
                    b1.hash.should eq(b2.hash)
         
     | 
| 
       139 
139 
     | 
    
         
             
                  end
         
     | 
| 
       140 
140 
     | 
    
         
             
                end
         
     | 
| 
       141 
141 
     | 
    
         | 
| 
       142 
142 
     | 
    
         
             
                describe '#to_s' do
         
     | 
| 
       143 
143 
     | 
    
         
             
                  it 'returns the bytes' do
         
     | 
| 
       144 
     | 
    
         
            -
                    buffer.append('hello world').to_s.should  
     | 
| 
      
 144 
     | 
    
         
            +
                    buffer.append('hello world').to_s.should eq('hello world')
         
     | 
| 
       145 
145 
     | 
    
         
             
                  end
         
     | 
| 
       146 
146 
     | 
    
         
             
                end
         
     | 
| 
       147 
147 
     | 
    
         | 
| 
       148 
148 
     | 
    
         
             
                describe '#to_str' do
         
     | 
| 
       149 
149 
     | 
    
         
             
                  it 'returns the bytes' do
         
     | 
| 
       150 
     | 
    
         
            -
                    buffer.append('hello world').to_str.should  
     | 
| 
      
 150 
     | 
    
         
            +
                    buffer.append('hello world').to_str.should eq('hello world')
         
     | 
| 
       151 
151 
     | 
    
         
             
                  end
         
     | 
| 
       152 
152 
     | 
    
         
             
                end
         
     | 
| 
       153 
153 
     | 
    
         | 
| 
       154 
154 
     | 
    
         
             
                describe '#inspect' do
         
     | 
| 
       155 
155 
     | 
    
         
             
                  it 'returns the bytes wrapped in ByteBuffer(...)' do
         
     | 
| 
       156 
156 
     | 
    
         
             
                    buffer.append("\xca\xfe")
         
     | 
| 
       157 
     | 
    
         
            -
                    buffer.inspect.should  
     | 
| 
      
 157 
     | 
    
         
            +
                    buffer.inspect.should eq('#<Ione::ByteBuffer: "\xCA\xFE">')
         
     | 
| 
       158 
158 
     | 
    
         
             
                  end
         
     | 
| 
       159 
159 
     | 
    
         
             
                end
         
     | 
| 
       160 
160 
     | 
    
         | 
| 
         @@ -162,12 +162,12 @@ module Ione 
     | 
|
| 
       162 
162 
     | 
    
         
             
                  it 'discards the specified number of bytes from the front of the buffer' do
         
     | 
| 
       163 
163 
     | 
    
         
             
                    buffer.append('hello world')
         
     | 
| 
       164 
164 
     | 
    
         
             
                    buffer.discard(4)
         
     | 
| 
       165 
     | 
    
         
            -
                    buffer.should  
     | 
| 
      
 165 
     | 
    
         
            +
                    buffer.should eq(ByteBuffer.new('o world'))
         
     | 
| 
       166 
166 
     | 
    
         
             
                  end
         
     | 
| 
       167 
167 
     | 
    
         | 
| 
       168 
168 
     | 
    
         
             
                  it 'returns the byte buffer' do
         
     | 
| 
       169 
169 
     | 
    
         
             
                    buffer.append('hello world')
         
     | 
| 
       170 
     | 
    
         
            -
                    buffer.discard(4).should  
     | 
| 
      
 170 
     | 
    
         
            +
                    buffer.discard(4).should eq(ByteBuffer.new('o world'))
         
     | 
| 
       171 
171 
     | 
    
         
             
                  end
         
     | 
| 
       172 
172 
     | 
    
         | 
| 
       173 
173 
     | 
    
         
             
                  it 'raises an error if the number of bytes in the buffer is fewer than the number to discard' do
         
     | 
| 
         @@ -185,14 +185,14 @@ module Ione 
     | 
|
| 
       185 
185 
     | 
    
         
             
                describe '#read' do
         
     | 
| 
       186 
186 
     | 
    
         
             
                  it 'returns the specified number of bytes, as a string' do
         
     | 
| 
       187 
187 
     | 
    
         
             
                    buffer.append('hello')
         
     | 
| 
       188 
     | 
    
         
            -
                    buffer.read(4).should  
     | 
| 
      
 188 
     | 
    
         
            +
                    buffer.read(4).should eq('hell')
         
     | 
| 
       189 
189 
     | 
    
         
             
                  end
         
     | 
| 
       190 
190 
     | 
    
         | 
| 
       191 
191 
     | 
    
         
             
                  it 'removes the bytes from the buffer' do
         
     | 
| 
       192 
192 
     | 
    
         
             
                    buffer.append('hello')
         
     | 
| 
       193 
193 
     | 
    
         
             
                    buffer.read(3)
         
     | 
| 
       194 
     | 
    
         
            -
                    buffer.should  
     | 
| 
       195 
     | 
    
         
            -
                    buffer.read(2).should  
     | 
| 
      
 194 
     | 
    
         
            +
                    buffer.should eq(ByteBuffer.new('lo'))
         
     | 
| 
      
 195 
     | 
    
         
            +
                    buffer.read(2).should eq('lo')
         
     | 
| 
       196 
196 
     | 
    
         
             
                  end
         
     | 
| 
       197 
197 
     | 
    
         | 
| 
       198 
198 
     | 
    
         
             
                  it 'raises an error if there are not enough bytes' do
         
     | 
| 
         @@ -208,22 +208,22 @@ module Ione 
     | 
|
| 
       208 
208 
     | 
    
         | 
| 
       209 
209 
     | 
    
         
             
                  it 'returns a string with binary encoding' do
         
     | 
| 
       210 
210 
     | 
    
         
             
                    buffer.append('hello')
         
     | 
| 
       211 
     | 
    
         
            -
                    buffer.read(4).encoding.should  
     | 
| 
      
 211 
     | 
    
         
            +
                    buffer.read(4).encoding.should eq(::Encoding::BINARY)
         
     | 
| 
       212 
212 
     | 
    
         
             
                    buffer.append('∆')
         
     | 
| 
       213 
     | 
    
         
            -
                    buffer.read(2).encoding.should  
     | 
| 
      
 213 
     | 
    
         
            +
                    buffer.read(2).encoding.should eq(::Encoding::BINARY)
         
     | 
| 
       214 
214 
     | 
    
         
             
                  end
         
     | 
| 
       215 
215 
     | 
    
         
             
                end
         
     | 
| 
       216 
216 
     | 
    
         | 
| 
       217 
217 
     | 
    
         
             
                describe '#read_int' do
         
     | 
| 
       218 
218 
     | 
    
         
             
                  it 'returns the first four bytes interpreted as an int' do
         
     | 
| 
       219 
219 
     | 
    
         
             
                    buffer.append("\xca\xfe\xba\xbe\x01")
         
     | 
| 
       220 
     | 
    
         
            -
                    buffer.read_int.should  
     | 
| 
      
 220 
     | 
    
         
            +
                    buffer.read_int.should eq(0xcafebabe)
         
     | 
| 
       221 
221 
     | 
    
         
             
                  end
         
     | 
| 
       222 
222 
     | 
    
         | 
| 
       223 
223 
     | 
    
         
             
                  it 'removes the bytes from the buffer' do
         
     | 
| 
       224 
224 
     | 
    
         
             
                    buffer.append("\xca\xfe\xba\xbe\x01")
         
     | 
| 
       225 
225 
     | 
    
         
             
                    buffer.read_int
         
     | 
| 
       226 
     | 
    
         
            -
                    buffer.should  
     | 
| 
      
 226 
     | 
    
         
            +
                    buffer.should eq(ByteBuffer.new("\x01"))
         
     | 
| 
       227 
227 
     | 
    
         
             
                  end
         
     | 
| 
       228 
228 
     | 
    
         | 
| 
       229 
229 
     | 
    
         
             
                  it 'raises an error if there are not enough bytes' do
         
     | 
| 
         @@ -235,13 +235,13 @@ module Ione 
     | 
|
| 
       235 
235 
     | 
    
         
             
                describe '#read_short' do
         
     | 
| 
       236 
236 
     | 
    
         
             
                  it 'returns the first two bytes interpreted as a short' do
         
     | 
| 
       237 
237 
     | 
    
         
             
                    buffer.append("\xca\xfe\x01")
         
     | 
| 
       238 
     | 
    
         
            -
                    buffer.read_short.should  
     | 
| 
      
 238 
     | 
    
         
            +
                    buffer.read_short.should eq(0xcafe)
         
     | 
| 
       239 
239 
     | 
    
         
             
                  end
         
     | 
| 
       240 
240 
     | 
    
         | 
| 
       241 
241 
     | 
    
         
             
                  it 'removes the bytes from the buffer' do
         
     | 
| 
       242 
242 
     | 
    
         
             
                    buffer.append("\xca\xfe\x01")
         
     | 
| 
       243 
243 
     | 
    
         
             
                    buffer.read_short
         
     | 
| 
       244 
     | 
    
         
            -
                    buffer.should  
     | 
| 
      
 244 
     | 
    
         
            +
                    buffer.should eq(ByteBuffer.new("\x01"))
         
     | 
| 
       245 
245 
     | 
    
         
             
                  end
         
     | 
| 
       246 
246 
     | 
    
         | 
| 
       247 
247 
     | 
    
         
             
                  it 'raises an error if there are not enough bytes' do
         
     | 
| 
         @@ -253,14 +253,14 @@ module Ione 
     | 
|
| 
       253 
253 
     | 
    
         
             
                describe '#read_byte' do
         
     | 
| 
       254 
254 
     | 
    
         
             
                  it 'returns the first bytes interpreted as an int' do
         
     | 
| 
       255 
255 
     | 
    
         
             
                    buffer.append("\x10\x01")
         
     | 
| 
       256 
     | 
    
         
            -
                    buffer.read_byte.should  
     | 
| 
       257 
     | 
    
         
            -
                    buffer.read_byte.should  
     | 
| 
      
 256 
     | 
    
         
            +
                    buffer.read_byte.should eq(0x10)
         
     | 
| 
      
 257 
     | 
    
         
            +
                    buffer.read_byte.should eq(0x01)
         
     | 
| 
       258 
258 
     | 
    
         
             
                  end
         
     | 
| 
       259 
259 
     | 
    
         | 
| 
       260 
260 
     | 
    
         
             
                  it 'removes the byte from the buffer' do
         
     | 
| 
       261 
261 
     | 
    
         
             
                    buffer.append("\x10\x01")
         
     | 
| 
       262 
262 
     | 
    
         
             
                    buffer.read_byte
         
     | 
| 
       263 
     | 
    
         
            -
                    buffer.should  
     | 
| 
      
 263 
     | 
    
         
            +
                    buffer.should eq(ByteBuffer.new("\x01"))
         
     | 
| 
       264 
264 
     | 
    
         
             
                  end
         
     | 
| 
       265 
265 
     | 
    
         | 
| 
       266 
266 
     | 
    
         
             
                  it 'raises an error if there are no bytes' do
         
     | 
| 
         @@ -269,8 +269,8 @@ module Ione 
     | 
|
| 
       269 
269 
     | 
    
         | 
| 
       270 
270 
     | 
    
         
             
                  it 'can interpret the byte as signed' do
         
     | 
| 
       271 
271 
     | 
    
         
             
                    buffer.append("\x81\x02")
         
     | 
| 
       272 
     | 
    
         
            -
                    buffer.read_byte(true).should  
     | 
| 
       273 
     | 
    
         
            -
                    buffer.read_byte(true).should  
     | 
| 
      
 272 
     | 
    
         
            +
                    buffer.read_byte(true).should eq(-127)
         
     | 
| 
      
 273 
     | 
    
         
            +
                    buffer.read_byte(true).should eq(2)
         
     | 
| 
       274 
274 
     | 
    
         
             
                  end
         
     | 
| 
       275 
275 
     | 
    
         
             
                end
         
     | 
| 
       276 
276 
     | 
    
         | 
| 
         @@ -278,14 +278,14 @@ module Ione 
     | 
|
| 
       278 
278 
     | 
    
         
             
                  it 'changes the bytes at the specified location' do
         
     | 
| 
       279 
279 
     | 
    
         
             
                    buffer.append('foo bar')
         
     | 
| 
       280 
280 
     | 
    
         
             
                    buffer.update(4, 'baz')
         
     | 
| 
       281 
     | 
    
         
            -
                    buffer.to_s.should  
     | 
| 
      
 281 
     | 
    
         
            +
                    buffer.to_s.should eq('foo baz')
         
     | 
| 
       282 
282 
     | 
    
         
             
                  end
         
     | 
| 
       283 
283 
     | 
    
         | 
| 
       284 
284 
     | 
    
         
             
                  it 'handles updates after a read' do
         
     | 
| 
       285 
285 
     | 
    
         
             
                    buffer.append('foo bar')
         
     | 
| 
       286 
286 
     | 
    
         
             
                    buffer.read(1)
         
     | 
| 
       287 
287 
     | 
    
         
             
                    buffer.update(3, 'baz')
         
     | 
| 
       288 
     | 
    
         
            -
                    buffer.to_s.should  
     | 
| 
      
 288 
     | 
    
         
            +
                    buffer.to_s.should eq('oo baz')
         
     | 
| 
       289 
289 
     | 
    
         
             
                  end
         
     | 
| 
       290 
290 
     | 
    
         | 
| 
       291 
291 
     | 
    
         
             
                  it 'handles updates after multiple reads and appends' do
         
     | 
| 
         @@ -295,7 +295,7 @@ module Ione 
     | 
|
| 
       295 
295 
     | 
    
         
             
                    buffer.update(4, 'baz')
         
     | 
| 
       296 
296 
     | 
    
         
             
                    buffer.append('yyyy')
         
     | 
| 
       297 
297 
     | 
    
         
             
                    buffer.read(1)
         
     | 
| 
       298 
     | 
    
         
            -
                    buffer.to_s.should  
     | 
| 
      
 298 
     | 
    
         
            +
                    buffer.to_s.should eq('o bbazyyyy')
         
     | 
| 
       299 
299 
     | 
    
         
             
                  end
         
     | 
| 
       300 
300 
     | 
    
         | 
| 
       301 
301 
     | 
    
         
             
                  it 'returns itself' do
         
     | 
| 
         @@ -335,12 +335,12 @@ module Ione 
     | 
|
| 
       335 
335 
     | 
    
         
             
                describe '#index' do
         
     | 
| 
       336 
336 
     | 
    
         
             
                  it 'returns the first index of the specified substring' do
         
     | 
| 
       337 
337 
     | 
    
         
             
                    buffer.append('fizz buzz')
         
     | 
| 
       338 
     | 
    
         
            -
                    buffer.index('zz').should  
     | 
| 
      
 338 
     | 
    
         
            +
                    buffer.index('zz').should eq(2)
         
     | 
| 
       339 
339 
     | 
    
         
             
                  end
         
     | 
| 
       340 
340 
     | 
    
         | 
| 
       341 
341 
     | 
    
         
             
                  it 'returns the first index of the specified substring, after the specified index' do
         
     | 
| 
       342 
342 
     | 
    
         
             
                    buffer.append('fizz buzz')
         
     | 
| 
       343 
     | 
    
         
            -
                    buffer.index('zz', 3).should  
     | 
| 
      
 343 
     | 
    
         
            +
                    buffer.index('zz', 3).should eq(7)
         
     | 
| 
       344 
344 
     | 
    
         
             
                  end
         
     | 
| 
       345 
345 
     | 
    
         | 
| 
       346 
346 
     | 
    
         
             
                  it 'returns nil when the substring is not found' do
         
     | 
| 
         @@ -352,14 +352,14 @@ module Ione 
     | 
|
| 
       352 
352 
     | 
    
         
             
                    buffer.append('foo bar')
         
     | 
| 
       353 
353 
     | 
    
         
             
                    buffer.read(1)
         
     | 
| 
       354 
354 
     | 
    
         
             
                    buffer.append(' baz baz')
         
     | 
| 
       355 
     | 
    
         
            -
                    buffer.index('baz', 8).should  
     | 
| 
      
 355 
     | 
    
         
            +
                    buffer.index('baz', 8).should eq(11)
         
     | 
| 
       356 
356 
     | 
    
         
             
                  end
         
     | 
| 
       357 
357 
     | 
    
         | 
| 
       358 
358 
     | 
    
         
             
                  it 'returns the first index when the matching substring spans the read and write buffer' do
         
     | 
| 
       359 
359 
     | 
    
         
             
                    buffer.append('foo bar')
         
     | 
| 
       360 
360 
     | 
    
         
             
                    buffer.read(1)
         
     | 
| 
       361 
361 
     | 
    
         
             
                    buffer.append('bar barbar')
         
     | 
| 
       362 
     | 
    
         
            -
                    buffer.index('barbar', 0).should  
     | 
| 
      
 362 
     | 
    
         
            +
                    buffer.index('barbar', 0).should eq(3)
         
     | 
| 
       363 
363 
     | 
    
         
             
                  end
         
     | 
| 
       364 
364 
     | 
    
         | 
| 
       365 
365 
     | 
    
         
             
                  it 'returns nil when the substring does not fit in the search space' do
         
     | 
    
        data/spec/ione/future_spec.rb
    CHANGED
    
    | 
         @@ -91,7 +91,7 @@ module Ione 
     | 
|
| 
       91 
91 
     | 
    
         
             
                    promise.try do
         
     | 
| 
       92 
92 
     | 
    
         
             
                      3 + 4
         
     | 
| 
       93 
93 
     | 
    
         
             
                    end
         
     | 
| 
       94 
     | 
    
         
            -
                    promise.future.value.should  
     | 
| 
      
 94 
     | 
    
         
            +
                    promise.future.value.should eq(7)
         
     | 
| 
       95 
95 
     | 
    
         
             
                  end
         
     | 
| 
       96 
96 
     | 
    
         | 
| 
       97 
97 
     | 
    
         
             
                  it 'fails the promise when the block raises an error' do
         
     | 
| 
         @@ -105,7 +105,7 @@ module Ione 
     | 
|
| 
       105 
105 
     | 
    
         
             
                    promise.try(:foo, 3) do |a, b|
         
     | 
| 
       106 
106 
     | 
    
         
             
                      a.length + b
         
     | 
| 
       107 
107 
     | 
    
         
             
                    end
         
     | 
| 
       108 
     | 
    
         
            -
                    promise.future.value.should  
     | 
| 
      
 108 
     | 
    
         
            +
                    promise.future.value.should eq(6)
         
     | 
| 
       109 
109 
     | 
    
         
             
                  end
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
                  it 'returns nil' do
         
     | 
| 
         @@ -216,8 +216,8 @@ module Ione 
     | 
|
| 
       216 
216 
     | 
    
         
             
                      future.on_complete { |v, _| v1 = v }
         
     | 
| 
       217 
217 
     | 
    
         
             
                      future.on_complete { |v, _| v2 = v }
         
     | 
| 
       218 
218 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       219 
     | 
    
         
            -
                      v1.should  
     | 
| 
       220 
     | 
    
         
            -
                      v2.should  
     | 
| 
      
 219 
     | 
    
         
            +
                      v1.should eq('bar')
         
     | 
| 
      
 220 
     | 
    
         
            +
                      v2.should eq('bar')
         
     | 
| 
       221 
221 
     | 
    
         
             
                    end
         
     | 
| 
       222 
222 
     | 
    
         | 
| 
       223 
223 
     | 
    
         
             
                    it 'passes future as the third parameter to the block when it expects three arguments' do
         
     | 
| 
         @@ -319,15 +319,15 @@ module Ione 
     | 
|
| 
       319 
319 
     | 
    
         
             
                      future.on_complete { |f| raise 'Blurgh' }
         
     | 
| 
       320 
320 
     | 
    
         
             
                      future.on_complete { |f| value = f.value }
         
     | 
| 
       321 
321 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       322 
     | 
    
         
            -
                      value.should  
     | 
| 
      
 322 
     | 
    
         
            +
                      value.should eq('bar')
         
     | 
| 
       323 
323 
     | 
    
         
             
                    end
         
     | 
| 
       324 
324 
     | 
    
         | 
| 
       325 
325 
     | 
    
         
             
                    it 'notifies all listeners when the promise fails, even when one raises an error' do
         
     | 
| 
       326 
326 
     | 
    
         
             
                      err = nil
         
     | 
| 
       327 
327 
     | 
    
         
             
                      future.on_complete { |f| raise 'Blurgh' }
         
     | 
| 
       328 
     | 
    
         
            -
                      future.on_complete { |f| begin; f.value; rescue =>  
     | 
| 
      
 328 
     | 
    
         
            +
                      future.on_complete { |f| begin; f.value; rescue => e; err = e; end }
         
     | 
| 
       329 
329 
     | 
    
         
             
                      promise.fail(error)
         
     | 
| 
       330 
     | 
    
         
            -
                      err.message.should  
     | 
| 
      
 330 
     | 
    
         
            +
                      err.message.should eq('bork')
         
     | 
| 
       331 
331 
     | 
    
         
             
                    end
         
     | 
| 
       332 
332 
     | 
    
         | 
| 
       333 
333 
     | 
    
         
             
                    it 'notifies listeners registered after the promise was fulfilled' do
         
     | 
| 
         @@ -335,7 +335,7 @@ module Ione 
     | 
|
| 
       335 
335 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       336 
336 
     | 
    
         
             
                      future.on_complete { |vv, ee, ff| v = vv; e = ee; f = ff }
         
     | 
| 
       337 
337 
     | 
    
         
             
                      f.should equal(future)
         
     | 
| 
       338 
     | 
    
         
            -
                      v.should  
     | 
| 
      
 338 
     | 
    
         
            +
                      v.should eq('bar')
         
     | 
| 
       339 
339 
     | 
    
         
             
                      e.should be_nil
         
     | 
| 
       340 
340 
     | 
    
         
             
                    end
         
     | 
| 
       341 
341 
     | 
    
         | 
| 
         @@ -345,7 +345,7 @@ module Ione 
     | 
|
| 
       345 
345 
     | 
    
         
             
                      future.on_complete { |vv, ee, ff| v = vv; e = ee; f = ff }
         
     | 
| 
       346 
346 
     | 
    
         
             
                      f.should equal(future)
         
     | 
| 
       347 
347 
     | 
    
         
             
                      v.should be_nil
         
     | 
| 
       348 
     | 
    
         
            -
                      e.message.should  
     | 
| 
      
 348 
     | 
    
         
            +
                      e.message.should eq('bork')
         
     | 
| 
       349 
349 
     | 
    
         
             
                    end
         
     | 
| 
       350 
350 
     | 
    
         | 
| 
       351 
351 
     | 
    
         
             
                    it 'notifies listeners registered after the promise failed' do
         
     | 
| 
         @@ -376,8 +376,8 @@ module Ione 
     | 
|
| 
       376 
376 
     | 
    
         
             
                      future.on_value { |v| v1 = v }
         
     | 
| 
       377 
377 
     | 
    
         
             
                      future.on_value { |v| v2 = v }
         
     | 
| 
       378 
378 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       379 
     | 
    
         
            -
                      v1.should  
     | 
| 
       380 
     | 
    
         
            -
                      v2.should  
     | 
| 
      
 379 
     | 
    
         
            +
                      v1.should eq('bar')
         
     | 
| 
      
 380 
     | 
    
         
            +
                      v2.should eq('bar')
         
     | 
| 
       381 
381 
     | 
    
         
             
                    end
         
     | 
| 
       382 
382 
     | 
    
         | 
| 
       383 
383 
     | 
    
         
             
                    it 'notifies all listeners even when one raises an error' do
         
     | 
| 
         @@ -385,7 +385,7 @@ module Ione 
     | 
|
| 
       385 
385 
     | 
    
         
             
                      future.on_value { |v| raise 'Blurgh' }
         
     | 
| 
       386 
386 
     | 
    
         
             
                      future.on_value { |v| value = v }
         
     | 
| 
       387 
387 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       388 
     | 
    
         
            -
                      value.should  
     | 
| 
      
 388 
     | 
    
         
            +
                      value.should eq('bar')
         
     | 
| 
       389 
389 
     | 
    
         
             
                    end
         
     | 
| 
       390 
390 
     | 
    
         | 
| 
       391 
391 
     | 
    
         
             
                    it 'notifies listeners registered after the promise was resolved' do
         
     | 
| 
         @@ -393,8 +393,8 @@ module Ione 
     | 
|
| 
       393 
393 
     | 
    
         
             
                      promise.fulfill('bar')
         
     | 
| 
       394 
394 
     | 
    
         
             
                      future.on_value { |v| v1 = v }
         
     | 
| 
       395 
395 
     | 
    
         
             
                      future.on_value { |v| v2 = v }
         
     | 
| 
       396 
     | 
    
         
            -
                      v1.should  
     | 
| 
       397 
     | 
    
         
            -
                      v2.should  
     | 
| 
      
 396 
     | 
    
         
            +
                      v1.should eq('bar')
         
     | 
| 
      
 397 
     | 
    
         
            +
                      v2.should eq('bar')
         
     | 
| 
       398 
398 
     | 
    
         
             
                    end
         
     | 
| 
       399 
399 
     | 
    
         | 
| 
       400 
400 
     | 
    
         
             
                    it 'does not raise any error when the listener raises an error when already resolved' do
         
     | 
| 
         @@ -479,7 +479,7 @@ module Ione 
     | 
|
| 
       479 
479 
     | 
    
         
             
                      p.fulfill('bar')
         
     | 
| 
       480 
480 
     | 
    
         
             
                    end
         
     | 
| 
       481 
481 
     | 
    
         
             
                    d.value
         
     | 
| 
       482 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 482 
     | 
    
         
            +
                    future.value.should eq('bar')
         
     | 
| 
       483 
483 
     | 
    
         
             
                  end
         
     | 
| 
       484 
484 
     | 
    
         | 
| 
       485 
485 
     | 
    
         
             
                  it 'blocks on #value until completed, when value is nil' do
         
     | 
| 
         @@ -506,7 +506,7 @@ module Ione 
     | 
|
| 
       506 
506 
     | 
    
         
             
                    end
         
     | 
| 
       507 
507 
     | 
    
         
             
                    sleep 0.1
         
     | 
| 
       508 
508 
     | 
    
         
             
                    promise.fulfill(:hello)
         
     | 
| 
       509 
     | 
    
         
            -
                    listeners.map(&:value).should  
     | 
| 
      
 509 
     | 
    
         
            +
                    listeners.map(&:value).should eq(Array.new(10, :hello))
         
     | 
| 
       510 
510 
     | 
    
         
             
                  end
         
     | 
| 
       511 
511 
     | 
    
         | 
| 
       512 
512 
     | 
    
         
             
                  it 'is aliased as #get' do
         
     | 
| 
         @@ -524,7 +524,7 @@ module Ione 
     | 
|
| 
       524 
524 
     | 
    
         
             
                      f = p.future.map { |v| v * 2 }
         
     | 
| 
       525 
525 
     | 
    
         
             
                      f.on_value { |v| mapped_value = v }
         
     | 
| 
       526 
526 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       527 
     | 
    
         
            -
                      mapped_value.should  
     | 
| 
      
 527 
     | 
    
         
            +
                      mapped_value.should eq(3 * 2)
         
     | 
| 
       528 
528 
     | 
    
         
             
                    end
         
     | 
| 
       529 
529 
     | 
    
         | 
| 
       530 
530 
     | 
    
         
             
                    it 'will be resolved with the specified value' do
         
     | 
| 
         @@ -533,7 +533,7 @@ module Ione 
     | 
|
| 
       533 
533 
     | 
    
         
             
                      f = p.future.map(7)
         
     | 
| 
       534 
534 
     | 
    
         
             
                      f.on_value { |v| mapped_value = v }
         
     | 
| 
       535 
535 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       536 
     | 
    
         
            -
                      mapped_value.should  
     | 
| 
      
 536 
     | 
    
         
            +
                      mapped_value.should eq(7)
         
     | 
| 
       537 
537 
     | 
    
         
             
                    end
         
     | 
| 
       538 
538 
     | 
    
         | 
| 
       539 
539 
     | 
    
         
             
                    it 'will be resolved with the result of the given block, even if a value is specified' do
         
     | 
| 
         @@ -542,7 +542,7 @@ module Ione 
     | 
|
| 
       542 
542 
     | 
    
         
             
                      f = p.future.map(7) { |v| v * 2 }
         
     | 
| 
       543 
543 
     | 
    
         
             
                      f.on_value { |v| mapped_value = v }
         
     | 
| 
       544 
544 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       545 
     | 
    
         
            -
                      mapped_value.should  
     | 
| 
      
 545 
     | 
    
         
            +
                      mapped_value.should eq(3 * 2)
         
     | 
| 
       546 
546 
     | 
    
         
             
                    end
         
     | 
| 
       547 
547 
     | 
    
         | 
| 
       548 
548 
     | 
    
         
             
                    it 'will be resolved with nil when neither value nor block is specified' do
         
     | 
| 
         @@ -581,7 +581,7 @@ module Ione 
     | 
|
| 
       581 
581 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       582 
582 
     | 
    
         
             
                      f = p.future.flat_map { |v| Future.resolved(v * 2) }
         
     | 
| 
       583 
583 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       584 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 584 
     | 
    
         
            +
                      f.value.should eq(3 * 2)
         
     | 
| 
       585 
585 
     | 
    
         
             
                    end
         
     | 
| 
       586 
586 
     | 
    
         | 
| 
       587 
587 
     | 
    
         
             
                    it 'fails when the block raises an error' do
         
     | 
| 
         @@ -598,7 +598,7 @@ module Ione 
     | 
|
| 
       598 
598 
     | 
    
         
             
                    p = Promise.new
         
     | 
| 
       599 
599 
     | 
    
         
             
                    f = p.future.flat_map { fake_future }
         
     | 
| 
       600 
600 
     | 
    
         
             
                    p.fulfill
         
     | 
| 
       601 
     | 
    
         
            -
                    f.value.should  
     | 
| 
      
 601 
     | 
    
         
            +
                    f.value.should eq(:foobar)
         
     | 
| 
       602 
602 
     | 
    
         
             
                  end
         
     | 
| 
       603 
603 
     | 
    
         
             
                end
         
     | 
| 
       604 
604 
     | 
    
         | 
| 
         @@ -608,7 +608,7 @@ module Ione 
     | 
|
| 
       608 
608 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       609 
609 
     | 
    
         
             
                      f = p.future.then { |v| Future.resolved(v * 2) }
         
     | 
| 
       610 
610 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       611 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 611 
     | 
    
         
            +
                      f.value.should eq(3 * 2)
         
     | 
| 
       612 
612 
     | 
    
         
             
                    end
         
     | 
| 
       613 
613 
     | 
    
         
             
                  end
         
     | 
| 
       614 
614 
     | 
    
         | 
| 
         @@ -620,7 +620,7 @@ module Ione 
     | 
|
| 
       620 
620 
     | 
    
         
             
                        p = Promise.new
         
     | 
| 
       621 
621 
     | 
    
         
             
                        f = p.future.then { |v| fake_future }
         
     | 
| 
       622 
622 
     | 
    
         
             
                        p.fulfill
         
     | 
| 
       623 
     | 
    
         
            -
                        f.value.should  
     | 
| 
      
 623 
     | 
    
         
            +
                        f.value.should eq(:foobar)
         
     | 
| 
       624 
624 
     | 
    
         
             
                      end
         
     | 
| 
       625 
625 
     | 
    
         
             
                    end
         
     | 
| 
       626 
626 
     | 
    
         | 
| 
         @@ -641,7 +641,7 @@ module Ione 
     | 
|
| 
       641 
641 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       642 
642 
     | 
    
         
             
                      f = p.future.then { |v| v * 2 }
         
     | 
| 
       643 
643 
     | 
    
         
             
                      p.fulfill(3)
         
     | 
| 
       644 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 644 
     | 
    
         
            +
                      f.value.should eq(3 * 2)
         
     | 
| 
       645 
645 
     | 
    
         
             
                    end
         
     | 
| 
       646 
646 
     | 
    
         
             
                  end
         
     | 
| 
       647 
647 
     | 
    
         | 
| 
         @@ -662,21 +662,21 @@ module Ione 
     | 
|
| 
       662 
662 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       663 
663 
     | 
    
         
             
                      f = p.future.recover { 'foo' }
         
     | 
| 
       664 
664 
     | 
    
         
             
                      p.fail(error)
         
     | 
| 
       665 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 665 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       666 
666 
     | 
    
         
             
                    end
         
     | 
| 
       667 
667 
     | 
    
         | 
| 
       668 
668 
     | 
    
         
             
                    it 'resolves to a specfied value when the source future fails' do
         
     | 
| 
       669 
669 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       670 
670 
     | 
    
         
             
                      f = p.future.recover('bar')
         
     | 
| 
       671 
671 
     | 
    
         
             
                      p.fail(error)
         
     | 
| 
       672 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 672 
     | 
    
         
            +
                      f.value.should eq('bar')
         
     | 
| 
       673 
673 
     | 
    
         
             
                    end
         
     | 
| 
       674 
674 
     | 
    
         | 
| 
       675 
675 
     | 
    
         
             
                    it 'resovles to a value created by the block even when a value is specified when the source future fails' do
         
     | 
| 
       676 
676 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       677 
677 
     | 
    
         
             
                      f = p.future.recover('bar') { 'foo' }
         
     | 
| 
       678 
678 
     | 
    
         
             
                      p.fail(error)
         
     | 
| 
       679 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 679 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       680 
680 
     | 
    
         
             
                    end
         
     | 
| 
       681 
681 
     | 
    
         | 
| 
       682 
682 
     | 
    
         
             
                    it 'resolves to nil value when no value nor block is specified and the source future fails' do
         
     | 
| 
         @@ -690,14 +690,14 @@ module Ione 
     | 
|
| 
       690 
690 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       691 
691 
     | 
    
         
             
                      f = p.future.recover { |e| e.message }
         
     | 
| 
       692 
692 
     | 
    
         
             
                      p.fail(error)
         
     | 
| 
       693 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 693 
     | 
    
         
            +
                      f.value.should eq(error.message)
         
     | 
| 
       694 
694 
     | 
    
         
             
                    end
         
     | 
| 
       695 
695 
     | 
    
         | 
| 
       696 
696 
     | 
    
         
             
                    it 'resolves to the value of the source future when the source future is resolved' do
         
     | 
| 
       697 
697 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       698 
698 
     | 
    
         
             
                      f = p.future.recover { 'foo' }
         
     | 
| 
       699 
699 
     | 
    
         
             
                      p.fulfill('bar')
         
     | 
| 
       700 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 700 
     | 
    
         
            +
                      f.value.should eq('bar')
         
     | 
| 
       701 
701 
     | 
    
         
             
                    end
         
     | 
| 
       702 
702 
     | 
    
         | 
| 
       703 
703 
     | 
    
         
             
                    it 'fails with the error raised in the given block' do
         
     | 
| 
         @@ -717,17 +717,16 @@ module Ione 
     | 
|
| 
       717 
717 
     | 
    
         
             
                      f = p1.future.fallback { p2.future }
         
     | 
| 
       718 
718 
     | 
    
         
             
                      p1.fail(error)
         
     | 
| 
       719 
719 
     | 
    
         
             
                      p2.fulfill('foo')
         
     | 
| 
       720 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 720 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       721 
721 
     | 
    
         
             
                    end
         
     | 
| 
       722 
722 
     | 
    
         | 
| 
       723 
723 
     | 
    
         
             
                    it 'yields the error to the block' do
         
     | 
| 
       724 
     | 
    
         
            -
                       
     | 
| 
       725 
     | 
    
         
            -
                       
     | 
| 
       726 
     | 
    
         
            -
                      f = p1.future.fallback do |error|
         
     | 
| 
      
 724 
     | 
    
         
            +
                      p = Promise.new
         
     | 
| 
      
 725 
     | 
    
         
            +
                      f = p.future.fallback do |error|
         
     | 
| 
       727 
726 
     | 
    
         
             
                        Future.resolved(error.message)
         
     | 
| 
       728 
727 
     | 
    
         
             
                      end
         
     | 
| 
       729 
     | 
    
         
            -
                       
     | 
| 
       730 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 728 
     | 
    
         
            +
                      p.fail(error)
         
     | 
| 
      
 729 
     | 
    
         
            +
                      f.value.should eq(error.message)
         
     | 
| 
       731 
730 
     | 
    
         
             
                    end
         
     | 
| 
       732 
731 
     | 
    
         | 
| 
       733 
732 
     | 
    
         
             
                    it 'is resolved with the value of the source future when the source future fullfills' do
         
     | 
| 
         @@ -736,7 +735,7 @@ module Ione 
     | 
|
| 
       736 
735 
     | 
    
         
             
                      f = p1.future.fallback { p2.future }
         
     | 
| 
       737 
736 
     | 
    
         
             
                      p2.fulfill('bar')
         
     | 
| 
       738 
737 
     | 
    
         
             
                      p1.fulfill('foo')
         
     | 
| 
       739 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 738 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       740 
739 
     | 
    
         
             
                    end
         
     | 
| 
       741 
740 
     | 
    
         | 
| 
       742 
741 
     | 
    
         
             
                    it 'fails when the block raises an error' do
         
     | 
| 
         @@ -761,7 +760,7 @@ module Ione 
     | 
|
| 
       761 
760 
     | 
    
         
             
                      p = Promise.new
         
     | 
| 
       762 
761 
     | 
    
         
             
                      f = p.future.fallback { fake_future }
         
     | 
| 
       763 
762 
     | 
    
         
             
                      p.fail(error)
         
     | 
| 
       764 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 763 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       765 
764 
     | 
    
         
             
                    end
         
     | 
| 
       766 
765 
     | 
    
         
             
                  end
         
     | 
| 
       767 
766 
     | 
    
         
             
                end
         
     | 
| 
         @@ -771,7 +770,7 @@ module Ione 
     | 
|
| 
       771 
770 
     | 
    
         
             
                    future = Future.traverse([1, 2, 3]) do |element|
         
     | 
| 
       772 
771 
     | 
    
         
             
                      Future.resolved(element * 2)
         
     | 
| 
       773 
772 
     | 
    
         
             
                    end
         
     | 
| 
       774 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 773 
     | 
    
         
            +
                    future.value.should eq([2, 4, 6])
         
     | 
| 
       775 
774 
     | 
    
         
             
                  end
         
     | 
| 
       776 
775 
     | 
    
         | 
| 
       777 
776 
     | 
    
         
             
                  it 'fails if any of the source futures fail' do
         
     | 
| 
         @@ -800,12 +799,12 @@ module Ione 
     | 
|
| 
       800 
799 
     | 
    
         
             
                    fake_future = double(:fake_future)
         
     | 
| 
       801 
800 
     | 
    
         
             
                    fake_future.stub(:on_complete) { |&listener| listener.call(:foobar, nil) }
         
     | 
| 
       802 
801 
     | 
    
         
             
                    future = Future.traverse([1, 2, 3]) { fake_future }
         
     | 
| 
       803 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 802 
     | 
    
         
            +
                    future.value.should eq([:foobar, :foobar, :foobar])
         
     | 
| 
       804 
803 
     | 
    
         
             
                  end
         
     | 
| 
       805 
804 
     | 
    
         | 
| 
       806 
805 
     | 
    
         
             
                  it 'accepts an enumerable of values' do
         
     | 
| 
       807 
806 
     | 
    
         
             
                    future = Future.traverse([1, 2, 3].to_enum) { |v| Future.resolved(v * 2) }
         
     | 
| 
       808 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 807 
     | 
    
         
            +
                    future.value.should eq([2, 4, 6])
         
     | 
| 
       809 
808 
     | 
    
         
             
                  end
         
     | 
| 
       810 
809 
     | 
    
         
             
                end
         
     | 
| 
       811 
810 
     | 
    
         | 
| 
         @@ -819,7 +818,7 @@ module Ione 
     | 
|
| 
       819 
818 
     | 
    
         
             
                    future = Future.reduce(futures, {}) do |accumulator, value|
         
     | 
| 
       820 
819 
     | 
    
         
             
                      accumulator.merge(value)
         
     | 
| 
       821 
820 
     | 
    
         
             
                    end
         
     | 
| 
       822 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 821 
     | 
    
         
            +
                    future.value.should eq({'foo' => 'bar', 'qux' => 'baz', 'hello' => 'world'})
         
     | 
| 
       823 
822 
     | 
    
         
             
                  end
         
     | 
| 
       824 
823 
     | 
    
         | 
| 
       825 
824 
     | 
    
         
             
                  it 'accepts boolean accumulators' do
         
     | 
| 
         @@ -830,7 +829,7 @@ module Ione 
     | 
|
| 
       830 
829 
     | 
    
         
             
                    future = Future.reduce(futures, false) do |accumulator, value|
         
     | 
| 
       831 
830 
     | 
    
         
             
                      accumulator || value.empty?
         
     | 
| 
       832 
831 
     | 
    
         
             
                    end
         
     | 
| 
       833 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 832 
     | 
    
         
            +
                    future.value.should eq(true)
         
     | 
| 
       834 
833 
     | 
    
         
             
                  end
         
     | 
| 
       835 
834 
     | 
    
         | 
| 
       836 
835 
     | 
    
         
             
                  it 'calls the block with the values in the order of the source futures' do
         
     | 
| 
         @@ -844,7 +843,7 @@ module Ione 
     | 
|
| 
       844 
843 
     | 
    
         
             
                    promises[2].fulfill(2)
         
     | 
| 
       845 
844 
     | 
    
         
             
                    promises[4].fulfill(4)
         
     | 
| 
       846 
845 
     | 
    
         
             
                    promises[3].fulfill(3)
         
     | 
| 
       847 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 846 
     | 
    
         
            +
                    future.value.should eq([0, 1, 2, 3, 4])
         
     | 
| 
       848 
847 
     | 
    
         
             
                  end
         
     | 
| 
       849 
848 
     | 
    
         | 
| 
       850 
849 
     | 
    
         
             
                  it 'uses the first value as initial value when no intial value is given' do
         
     | 
| 
         @@ -856,7 +855,7 @@ module Ione 
     | 
|
| 
       856 
855 
     | 
    
         
             
                    promises[1].fulfill(2)
         
     | 
| 
       857 
856 
     | 
    
         
             
                    promises[0].fulfill(1)
         
     | 
| 
       858 
857 
     | 
    
         
             
                    promises[2].fulfill(3)
         
     | 
| 
       859 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 858 
     | 
    
         
            +
                    future.value.should eq(6)
         
     | 
| 
       860 
859 
     | 
    
         
             
                  end
         
     | 
| 
       861 
860 
     | 
    
         | 
| 
       862 
861 
     | 
    
         
             
                  it 'fails if any of the source futures fail' do
         
     | 
| 
         @@ -893,7 +892,7 @@ module Ione 
     | 
|
| 
       893 
892 
     | 
    
         | 
| 
       894 
893 
     | 
    
         
             
                  context 'when the list of futures is empty' do
         
     | 
| 
       895 
894 
     | 
    
         
             
                    it 'returns a future that resolves to the initial value' do
         
     | 
| 
       896 
     | 
    
         
            -
                      Future.reduce([], :foo).value.should  
     | 
| 
      
 895 
     | 
    
         
            +
                      Future.reduce([], :foo).value.should eq(:foo)
         
     | 
| 
       897 
896 
     | 
    
         
             
                    end
         
     | 
| 
       898 
897 
     | 
    
         | 
| 
       899 
898 
     | 
    
         
             
                    it 'returns a future that resolves to nil there is also no initial value' do
         
     | 
| 
         @@ -907,13 +906,13 @@ module Ione 
     | 
|
| 
       907 
906 
     | 
    
         
             
                    ff2.stub(:on_complete) { |&listener| listener.call(2, nil) }
         
     | 
| 
       908 
907 
     | 
    
         
             
                    ff3.stub(:on_complete) { |&listener| listener.call(3, nil) }
         
     | 
| 
       909 
908 
     | 
    
         
             
                    future = Future.reduce([ff1, ff2, ff3], 0) { |sum, n| sum + n }
         
     | 
| 
       910 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 909 
     | 
    
         
            +
                    future.value.should eq(6)
         
     | 
| 
       911 
910 
     | 
    
         
             
                  end
         
     | 
| 
       912 
911 
     | 
    
         | 
| 
       913 
912 
     | 
    
         
             
                  it 'accepts an enumerable of futures' do
         
     | 
| 
       914 
913 
     | 
    
         
             
                    futures = [Future.resolved(1), Future.resolved(2), Future.resolved(3)].to_enum
         
     | 
| 
       915 
914 
     | 
    
         
             
                    future = Future.reduce(futures, 0) { |sum, n| sum + n }
         
     | 
| 
       916 
     | 
    
         
            -
                    future.value.should  
     | 
| 
      
 915 
     | 
    
         
            +
                    future.value.should eq(6)
         
     | 
| 
       917 
916 
     | 
    
         
             
                  end
         
     | 
| 
       918 
917 
     | 
    
         | 
| 
       919 
918 
     | 
    
         
             
                  it 'handles a really long list of futures' do
         
     | 
| 
         @@ -932,7 +931,7 @@ module Ione 
     | 
|
| 
       932 
931 
     | 
    
         
             
                      promises[1].fulfill(1)
         
     | 
| 
       933 
932 
     | 
    
         
             
                      promises[0].fulfill(0)
         
     | 
| 
       934 
933 
     | 
    
         
             
                      promises[2].fulfill(2)
         
     | 
| 
       935 
     | 
    
         
            -
                      future.value.should  
     | 
| 
      
 934 
     | 
    
         
            +
                      future.value.should eq([1, 0, 2])
         
     | 
| 
       936 
935 
     | 
    
         
             
                    end
         
     | 
| 
       937 
936 
     | 
    
         | 
| 
       938 
937 
     | 
    
         
             
                    it 'fails if any of the source futures fail' do
         
     | 
| 
         @@ -963,7 +962,7 @@ module Ione 
     | 
|
| 
       963 
962 
     | 
    
         | 
| 
       964 
963 
     | 
    
         
             
                    context 'when the list of futures is empty' do
         
     | 
| 
       965 
964 
     | 
    
         
             
                      it 'returns a future that resolves to the initial value' do
         
     | 
| 
       966 
     | 
    
         
            -
                        Future.reduce([], :foo, ordered: false).value.should  
     | 
| 
      
 965 
     | 
    
         
            +
                        Future.reduce([], :foo, ordered: false).value.should eq(:foo)
         
     | 
| 
       967 
966 
     | 
    
         
             
                      end
         
     | 
| 
       968 
967 
     | 
    
         | 
| 
       969 
968 
     | 
    
         
             
                      it 'returns a future that resolves to nil there is also no initial value' do
         
     | 
| 
         @@ -1088,7 +1087,7 @@ module Ione 
     | 
|
| 
       1088 
1087 
     | 
    
         
             
                      p2.fulfill(2)
         
     | 
| 
       1089 
1088 
     | 
    
         
             
                      p1.fulfill(1)
         
     | 
| 
       1090 
1089 
     | 
    
         
             
                      p3.fulfill(3)
         
     | 
| 
       1091 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 1090 
     | 
    
         
            +
                      f.value.should eq([1, 2, 3])
         
     | 
| 
       1092 
1091 
     | 
    
         
             
                    end
         
     | 
| 
       1093 
1092 
     | 
    
         | 
| 
       1094 
1093 
     | 
    
         
             
                    it 'fails if any of the source futures fail' do
         
     | 
| 
         @@ -1106,20 +1105,20 @@ module Ione 
     | 
|
| 
       1106 
1105 
     | 
    
         
             
                    end
         
     | 
| 
       1107 
1106 
     | 
    
         | 
| 
       1108 
1107 
     | 
    
         
             
                    it 'completes with an empty list when no futures are given' do
         
     | 
| 
       1109 
     | 
    
         
            -
                      Future.all.value.should  
     | 
| 
      
 1108 
     | 
    
         
            +
                      Future.all.value.should eq([])
         
     | 
| 
       1110 
1109 
     | 
    
         
             
                    end
         
     | 
| 
       1111 
1110 
     | 
    
         | 
| 
       1112 
1111 
     | 
    
         
             
                    it 'completes with an empty list when an empty list is given' do
         
     | 
| 
       1113 
     | 
    
         
            -
                      Future.all([]).value.should  
     | 
| 
      
 1112 
     | 
    
         
            +
                      Future.all([]).value.should eq([])
         
     | 
| 
       1114 
1113 
     | 
    
         
             
                    end
         
     | 
| 
       1115 
1114 
     | 
    
         | 
| 
       1116 
1115 
     | 
    
         
             
                    it 'completes with an empty list when an empty enumerable is given' do
         
     | 
| 
       1117 
     | 
    
         
            -
                      Future.all([].to_enum).value.should  
     | 
| 
      
 1116 
     | 
    
         
            +
                      Future.all([].to_enum).value.should eq([])
         
     | 
| 
       1118 
1117 
     | 
    
         
             
                    end
         
     | 
| 
       1119 
1118 
     | 
    
         | 
| 
       1120 
1119 
     | 
    
         
             
                    it 'completes with a list of one item when a single future is given' do
         
     | 
| 
       1121 
1120 
     | 
    
         
             
                      f = Future.resolved(1)
         
     | 
| 
       1122 
     | 
    
         
            -
                      Future.all(f).value.should  
     | 
| 
      
 1121 
     | 
    
         
            +
                      Future.all(f).value.should eq([1])
         
     | 
| 
       1123 
1122 
     | 
    
         
             
                    end
         
     | 
| 
       1124 
1123 
     | 
    
         | 
| 
       1125 
1124 
     | 
    
         
             
                    it 'accepts a list of futures' do
         
     | 
| 
         @@ -1152,7 +1151,7 @@ module Ione 
     | 
|
| 
       1152 
1151 
     | 
    
         
             
                      ff2.stub(:on_complete) { |&listener| listener.call(2, nil) }
         
     | 
| 
       1153 
1152 
     | 
    
         
             
                      ff3.stub(:on_complete) { |&listener| listener.call(3, nil) }
         
     | 
| 
       1154 
1153 
     | 
    
         
             
                      future = Future.all(ff1, ff2, ff3)
         
     | 
| 
       1155 
     | 
    
         
            -
                      future.value.should  
     | 
| 
      
 1154 
     | 
    
         
            +
                      future.value.should eq([1, 2, 3])
         
     | 
| 
       1156 
1155 
     | 
    
         
             
                    end
         
     | 
| 
       1157 
1156 
     | 
    
         
             
                  end
         
     | 
| 
       1158 
1157 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1174,7 +1173,7 @@ module Ione 
     | 
|
| 
       1174 
1173 
     | 
    
         
             
                      p3 = Promise.new
         
     | 
| 
       1175 
1174 
     | 
    
         
             
                      f = Future.first(p1.future, p2.future, p3.future)
         
     | 
| 
       1176 
1175 
     | 
    
         
             
                      p2.fulfill('foo')
         
     | 
| 
       1177 
     | 
    
         
            -
                      f.value.should  
     | 
| 
      
 1176 
     | 
    
         
            +
                      f.value.should eq('foo')
         
     | 
| 
       1178 
1177 
     | 
    
         
             
                    end
         
     | 
| 
       1179 
1178 
     | 
    
         | 
| 
       1180 
1179 
     | 
    
         
             
                    it 'is unaffected by the fullfillment of the other futures' do
         
     | 
| 
         @@ -1226,7 +1225,7 @@ module Ione 
     | 
|
| 
       1226 
1225 
     | 
    
         
             
                    end
         
     | 
| 
       1227 
1226 
     | 
    
         | 
| 
       1228 
1227 
     | 
    
         
             
                    it 'completes with the value of the given future, when only one is given' do
         
     | 
| 
       1229 
     | 
    
         
            -
                      Future.first(Future.resolved('foo')).value.should  
     | 
| 
      
 1228 
     | 
    
         
            +
                      Future.first(Future.resolved('foo')).value.should eq('foo')
         
     | 
| 
       1230 
1229 
     | 
    
         
             
                    end
         
     | 
| 
       1231 
1230 
     | 
    
         | 
| 
       1232 
1231 
     | 
    
         
             
                    it 'accepts a list of futures' do
         
     | 
| 
         @@ -1250,7 +1249,7 @@ module Ione 
     | 
|
| 
       1250 
1249 
     | 
    
         
             
                      ff1.stub(:on_complete) { |&listener| listener.call(1, nil) }
         
     | 
| 
       1251 
1250 
     | 
    
         
             
                      ff2.stub(:on_complete) { |&listener| listener.call(2, nil) }
         
     | 
| 
       1252 
1251 
     | 
    
         
             
                      future = Future.first(ff1, ff2)
         
     | 
| 
       1253 
     | 
    
         
            -
                      future.value.should  
     | 
| 
      
 1252 
     | 
    
         
            +
                      future.value.should eq(1)
         
     | 
| 
       1254 
1253 
     | 
    
         
             
                    end
         
     | 
| 
       1255 
1254 
     | 
    
         
             
                  end
         
     | 
| 
       1256 
1255 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1276,14 +1275,14 @@ module Ione 
     | 
|
| 
       1276 
1275 
     | 
    
         
             
                    it 'calls its value callbacks immediately' do
         
     | 
| 
       1277 
1276 
     | 
    
         
             
                      value = nil
         
     | 
| 
       1278 
1277 
     | 
    
         
             
                      future.on_value { |v| value = v }
         
     | 
| 
       1279 
     | 
    
         
            -
                      value.should  
     | 
| 
      
 1278 
     | 
    
         
            +
                      value.should eq('hello world')
         
     | 
| 
       1280 
1279 
     | 
    
         
             
                    end
         
     | 
| 
       1281 
1280 
     | 
    
         | 
| 
       1282 
1281 
     | 
    
         
             
                    it 'calls its complete callbacks immediately' do
         
     | 
| 
       1283 
1282 
     | 
    
         
             
                      f, v = nil, nil
         
     | 
| 
       1284 
1283 
     | 
    
         
             
                      future.on_complete { |vv, _, ff| f = ff; v = vv }
         
     | 
| 
       1285 
1284 
     | 
    
         
             
                      f.should equal(future)
         
     | 
| 
       1286 
     | 
    
         
            -
                      v.should  
     | 
| 
      
 1285 
     | 
    
         
            +
                      v.should eq('hello world')
         
     | 
| 
       1287 
1286 
     | 
    
         
             
                    end
         
     | 
| 
       1288 
1287 
     | 
    
         | 
| 
       1289 
1288 
     | 
    
         
             
                    it 'calls its complete callbacks with the right arity' do
         
     | 
| 
         @@ -1293,11 +1292,11 @@ module Ione 
     | 
|
| 
       1293 
1292 
     | 
    
         
             
                      future.on_complete { |vv, ee, ff| f2 = ff }
         
     | 
| 
       1294 
1293 
     | 
    
         
             
                      f1.should equal(future)
         
     | 
| 
       1295 
1294 
     | 
    
         
             
                      f2.should equal(future)
         
     | 
| 
       1296 
     | 
    
         
            -
                      v.should  
     | 
| 
      
 1295 
     | 
    
         
            +
                      v.should eq('hello world')
         
     | 
| 
       1297 
1296 
     | 
    
         
             
                    end
         
     | 
| 
       1298 
1297 
     | 
    
         | 
| 
       1299 
1298 
     | 
    
         
             
                    it 'does not block on #value' do
         
     | 
| 
       1300 
     | 
    
         
            -
                      future.value.should  
     | 
| 
      
 1299 
     | 
    
         
            +
                      future.value.should eq('hello world')
         
     | 
| 
       1301 
1300 
     | 
    
         
             
                    end
         
     | 
| 
       1302 
1301 
     | 
    
         | 
| 
       1303 
1302 
     | 
    
         
             
                    it 'defaults to the value nil' do
         
     | 
| 
         @@ -1327,14 +1326,14 @@ module Ione 
     | 
|
| 
       1327 
1326 
     | 
    
         
             
                    it 'call its failure callbacks immediately' do
         
     | 
| 
       1328 
1327 
     | 
    
         
             
                      error = nil
         
     | 
| 
       1329 
1328 
     | 
    
         
             
                      future.on_failure { |e| error = e }
         
     | 
| 
       1330 
     | 
    
         
            -
                      error.message.should  
     | 
| 
      
 1329 
     | 
    
         
            +
                      error.message.should eq('bork')
         
     | 
| 
       1331 
1330 
     | 
    
         
             
                    end
         
     | 
| 
       1332 
1331 
     | 
    
         | 
| 
       1333 
1332 
     | 
    
         
             
                    it 'calls its complete callbacks immediately' do
         
     | 
| 
       1334 
1333 
     | 
    
         
             
                      f, e = nil, nil
         
     | 
| 
       1335 
1334 
     | 
    
         
             
                      future.on_complete { |_, ee, ff| f = ff; e = ee }
         
     | 
| 
       1336 
1335 
     | 
    
         
             
                      f.should equal(future)
         
     | 
| 
       1337 
     | 
    
         
            -
                      e.message.should  
     | 
| 
      
 1336 
     | 
    
         
            +
                      e.message.should eq('bork')
         
     | 
| 
       1338 
1337 
     | 
    
         
             
                    end
         
     | 
| 
       1339 
1338 
     | 
    
         | 
| 
       1340 
1339 
     | 
    
         
             
                    it 'calls its complete callbacks with the right arity' do
         
     | 
| 
         @@ -1344,7 +1343,7 @@ module Ione 
     | 
|
| 
       1344 
1343 
     | 
    
         
             
                      future.on_complete { |vv, ee, ff| f2 = ff }
         
     | 
| 
       1345 
1344 
     | 
    
         
             
                      f1.should equal(future)
         
     | 
| 
       1346 
1345 
     | 
    
         
             
                      f2.should equal(future)
         
     | 
| 
       1347 
     | 
    
         
            -
                      e.message.should  
     | 
| 
      
 1346 
     | 
    
         
            +
                      e.message.should eq('bork')
         
     | 
| 
       1348 
1347 
     | 
    
         
             
                    end
         
     | 
| 
       1349 
1348 
     | 
    
         | 
| 
       1350 
1349 
     | 
    
         
             
                    it 'does not block on #value' do
         
     | 
    
        data/spec/ione/heap_spec.rb
    CHANGED
    
    | 
         @@ -17,9 +17,9 @@ module Ione 
     | 
|
| 
       17 
17 
     | 
    
         
             
                  it 'returns the number of items in the heap' do
         
     | 
| 
       18 
18 
     | 
    
         
             
                    heap.push(13)
         
     | 
| 
       19 
19 
     | 
    
         
             
                    heap.push(100)
         
     | 
| 
       20 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 20 
     | 
    
         
            +
                    heap.size.should eq(2)
         
     | 
| 
       21 
21 
     | 
    
         
             
                    heap.push(101)
         
     | 
| 
       22 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 22 
     | 
    
         
            +
                    heap.size.should eq(3)
         
     | 
| 
       23 
23 
     | 
    
         
             
                  end
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
         @@ -40,7 +40,7 @@ module Ione 
     | 
|
| 
       40 
40 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       41 
41 
     | 
    
         
             
                    heap.push(6)
         
     | 
| 
       42 
42 
     | 
    
         
             
                    heap.push(5)
         
     | 
| 
       43 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 43 
     | 
    
         
            +
                    heap.size.should eq(4)
         
     | 
| 
       44 
44 
     | 
    
         
             
                  end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                  it 'is aliased as #<<' do
         
     | 
| 
         @@ -48,14 +48,14 @@ module Ione 
     | 
|
| 
       48 
48 
     | 
    
         
             
                    heap << 3
         
     | 
| 
       49 
49 
     | 
    
         
             
                    heap << 6
         
     | 
| 
       50 
50 
     | 
    
         
             
                    heap << 5
         
     | 
| 
       51 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 51 
     | 
    
         
            +
                    heap.size.should eq(4)
         
     | 
| 
       52 
52 
     | 
    
         
             
                  end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                  it 'does not add duplicates' do
         
     | 
| 
       55 
55 
     | 
    
         
             
                    heap << 3
         
     | 
| 
       56 
56 
     | 
    
         
             
                    heap << 3
         
     | 
| 
       57 
57 
     | 
    
         
             
                    heap << 3
         
     | 
| 
       58 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 58 
     | 
    
         
            +
                    heap.size.should eq(1)
         
     | 
| 
       59 
59 
     | 
    
         
             
                  end
         
     | 
| 
       60 
60 
     | 
    
         
             
                end
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
         @@ -66,21 +66,21 @@ module Ione 
     | 
|
| 
       66 
66 
     | 
    
         | 
| 
       67 
67 
     | 
    
         
             
                  it 'returns the only item when there is only one' do
         
     | 
| 
       68 
68 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       69 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
      
 69 
     | 
    
         
            +
                    heap.peek.should eq(3)
         
     | 
| 
       70 
70 
     | 
    
         
             
                  end
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
72 
     | 
    
         
             
                  it 'returns the smallest item' do
         
     | 
| 
       73 
73 
     | 
    
         
             
                    heap.push(10)
         
     | 
| 
       74 
74 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       75 
75 
     | 
    
         
             
                    heap.push(7)
         
     | 
| 
       76 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
      
 76 
     | 
    
         
            +
                    heap.peek.should eq(3)
         
     | 
| 
       77 
77 
     | 
    
         
             
                  end
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
                  it 'does not remove the item from the heap' do
         
     | 
| 
       80 
80 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       81 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
       82 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
       83 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
      
 81 
     | 
    
         
            +
                    heap.peek.should eq(3)
         
     | 
| 
      
 82 
     | 
    
         
            +
                    heap.peek.should eq(3)
         
     | 
| 
      
 83 
     | 
    
         
            +
                    heap.peek.should eq(3)
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
       85 
85 
     | 
    
         
             
                end
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
         @@ -91,7 +91,7 @@ module Ione 
     | 
|
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
                  it 'returns and removes the only item when there is only one' do
         
     | 
| 
       93 
93 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       94 
     | 
    
         
            -
                    heap.pop.should  
     | 
| 
      
 94 
     | 
    
         
            +
                    heap.pop.should eq(3)
         
     | 
| 
       95 
95 
     | 
    
         
             
                    heap.should be_empty
         
     | 
| 
       96 
96 
     | 
    
         
             
                  end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
         @@ -99,14 +99,14 @@ module Ione 
     | 
|
| 
       99 
99 
     | 
    
         
             
                    heap.push(10)
         
     | 
| 
       100 
100 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       101 
101 
     | 
    
         
             
                    heap.push(7)
         
     | 
| 
       102 
     | 
    
         
            -
                    heap.pop.should  
     | 
| 
       103 
     | 
    
         
            -
                    heap.pop.should  
     | 
| 
       104 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 102 
     | 
    
         
            +
                    heap.pop.should eq(3)
         
     | 
| 
      
 103 
     | 
    
         
            +
                    heap.pop.should eq(7)
         
     | 
| 
      
 104 
     | 
    
         
            +
                    heap.size.should eq(1)
         
     | 
| 
       105 
105 
     | 
    
         
             
                  end
         
     | 
| 
       106 
106 
     | 
    
         | 
| 
       107 
107 
     | 
    
         
             
                  it 'removes the item from the heap' do
         
     | 
| 
       108 
108 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       109 
     | 
    
         
            -
                    heap.pop.should  
     | 
| 
      
 109 
     | 
    
         
            +
                    heap.pop.should eq(3)
         
     | 
| 
       110 
110 
     | 
    
         
             
                    heap.pop.should be_nil
         
     | 
| 
       111 
111 
     | 
    
         
             
                  end
         
     | 
| 
       112 
112 
     | 
    
         
             
                end
         
     | 
| 
         @@ -125,8 +125,8 @@ module Ione 
     | 
|
| 
       125 
125 
     | 
    
         
             
                    heap.push(101)
         
     | 
| 
       126 
126 
     | 
    
         
             
                    heap.delete(4)
         
     | 
| 
       127 
127 
     | 
    
         
             
                    heap.pop
         
     | 
| 
       128 
     | 
    
         
            -
                    heap.peek.should  
     | 
| 
       129 
     | 
    
         
            -
                    heap.size.should  
     | 
| 
      
 128 
     | 
    
         
            +
                    heap.peek.should eq(100)
         
     | 
| 
      
 129 
     | 
    
         
            +
                    heap.size.should eq(2)
         
     | 
| 
       130 
130 
     | 
    
         
             
                  end
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
       132 
132 
     | 
    
         
             
                  it 'removes the last item from the heap' do
         
     | 
| 
         @@ -155,7 +155,7 @@ module Ione 
     | 
|
| 
       155 
155 
     | 
    
         
             
                    heap.push(3)
         
     | 
| 
       156 
156 
     | 
    
         
             
                    heap.push(4)
         
     | 
| 
       157 
157 
     | 
    
         
             
                    heap.push(5)
         
     | 
| 
       158 
     | 
    
         
            -
                    heap.delete(4).should  
     | 
| 
      
 158 
     | 
    
         
            +
                    heap.delete(4).should eq(4)
         
     | 
| 
       159 
159 
     | 
    
         
             
                  end
         
     | 
| 
       160 
160 
     | 
    
         | 
| 
       161 
161 
     | 
    
         
             
                  it 'returns nil when the item is not found' do
         
     | 
| 
         @@ -174,8 +174,8 @@ module Ione 
     | 
|
| 
       174 
174 
     | 
    
         
             
                      acceptor.bind
         
     | 
| 
       175 
175 
     | 
    
         
             
                      acceptor.read
         
     | 
| 
       176 
176 
     | 
    
         
             
                      accepted_handlers.should have(1).item
         
     | 
| 
       177 
     | 
    
         
            -
                      accepted_handlers.first.host.should  
     | 
| 
       178 
     | 
    
         
            -
                      accepted_handlers.first.port.should  
     | 
| 
      
 177 
     | 
    
         
            +
                      accepted_handlers.first.host.should eq('example.com')
         
     | 
| 
      
 178 
     | 
    
         
            +
                      accepted_handlers.first.port.should eq(3333)
         
     | 
| 
       179 
179 
     | 
    
         
             
                    end
         
     | 
| 
       180 
180 
     | 
    
         | 
| 
       181 
181 
     | 
    
         
             
                    it 'passes the unblocker along to the connection handler' do
         
     | 
| 
         @@ -197,9 +197,9 @@ module Ione 
     | 
|
| 
       197 
197 
     | 
    
         
             
                      acceptor.on_accept { |c| received_connection2 = c }
         
     | 
| 
       198 
198 
     | 
    
         
             
                      acceptor.bind
         
     | 
| 
       199 
199 
     | 
    
         
             
                      acceptor.read
         
     | 
| 
       200 
     | 
    
         
            -
                      received_connection1.host.should  
     | 
| 
       201 
     | 
    
         
            -
                      received_connection2.host.should  
     | 
| 
       202 
     | 
    
         
            -
                      received_connection2.port.should  
     | 
| 
      
 200 
     | 
    
         
            +
                      received_connection1.host.should eq('example.com')
         
     | 
| 
      
 201 
     | 
    
         
            +
                      received_connection2.host.should eq('example.com')
         
     | 
| 
      
 202 
     | 
    
         
            +
                      received_connection2.port.should eq(3333)
         
     | 
| 
       203 
203 
     | 
    
         
             
                    end
         
     | 
| 
       204 
204 
     | 
    
         | 
| 
       205 
205 
     | 
    
         
             
                    it 'ignores exceptions raised by the connection callback' do
         
     | 
| 
         @@ -40,7 +40,7 @@ shared_examples_for 'a connection' do |options| 
     | 
|
| 
       40 
40 
     | 
    
         
             
                  handler.on_closed { calls += 1 }
         
     | 
| 
       41 
41 
     | 
    
         
             
                  handler.close
         
     | 
| 
       42 
42 
     | 
    
         
             
                  handler.close
         
     | 
| 
       43 
     | 
    
         
            -
                  calls.should  
     | 
| 
      
 43 
     | 
    
         
            +
                  calls.should eq(1)
         
     | 
| 
       44 
44 
     | 
    
         
             
                end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                it 'returns false if it did nothing' do
         
     | 
| 
         @@ -238,7 +238,7 @@ shared_examples_for 'a connection' do |options| 
     | 
|
| 
       238 
238 
     | 
    
         
             
                    data = nil
         
     | 
| 
       239 
239 
     | 
    
         
             
                    handler.on_data { |d| data = d }
         
     | 
| 
       240 
240 
     | 
    
         
             
                    handler.read
         
     | 
| 
       241 
     | 
    
         
            -
                    data.should  
     | 
| 
      
 241 
     | 
    
         
            +
                    data.should eq('foo bar')
         
     | 
| 
       242 
242 
     | 
    
         
             
                  end
         
     | 
| 
       243 
243 
     | 
    
         | 
| 
       244 
244 
     | 
    
         
             
                  context 'when #read_nonblock raises an error' do
         
     | 
| 
         @@ -85,7 +85,7 @@ module Ione 
     | 
|
| 
       85 
85 
     | 
    
         
             
                        stopped_future.value
         
     | 
| 
       86 
86 
     | 
    
         
             
                        restarted_future.value
         
     | 
| 
       87 
87 
     | 
    
         
             
                        begin
         
     | 
| 
       88 
     | 
    
         
            -
                          sequence.should  
     | 
| 
      
 88 
     | 
    
         
            +
                          sequence.should eq([:stopped, :restarted])
         
     | 
| 
       89 
89 
     | 
    
         
             
                        ensure
         
     | 
| 
       90 
90 
     | 
    
         
             
                          reactor.stop
         
     | 
| 
       91 
91 
     | 
    
         
             
                          barrier.push(nil) while reactor.running?
         
     | 
| 
         @@ -136,8 +136,6 @@ module Ione 
     | 
|
| 
       136 
136 
     | 
    
         | 
| 
       137 
137 
     | 
    
         
             
                    context 'when already started' do
         
     | 
| 
       138 
138 
     | 
    
         
             
                      it 'is not started again' do
         
     | 
| 
       139 
     | 
    
         
            -
                        calls = 0
         
     | 
| 
       140 
     | 
    
         
            -
                        lock = Mutex.new
         
     | 
| 
       141 
139 
     | 
    
         
             
                        ticks = Queue.new
         
     | 
| 
       142 
140 
     | 
    
         
             
                        barrier = Queue.new
         
     | 
| 
       143 
141 
     | 
    
         
             
                        selector.handler do
         
     | 
| 
         @@ -239,7 +237,7 @@ module Ione 
     | 
|
| 
       239 
237 
     | 
    
         
             
                      reactor.on_error { |e| error = e }
         
     | 
| 
       240 
238 
     | 
    
         
             
                      reactor.start
         
     | 
| 
       241 
239 
     | 
    
         
             
                      await { error }
         
     | 
| 
       242 
     | 
    
         
            -
                      error.message.should  
     | 
| 
      
 240 
     | 
    
         
            +
                      error.message.should eq('Blurgh')
         
     | 
| 
       243 
241 
     | 
    
         
             
                    end
         
     | 
| 
       244 
242 
     | 
    
         | 
| 
       245 
243 
     | 
    
         
             
                    it 'calls the listener immediately when the reactor has already crashed' do
         
     | 
| 
         @@ -269,16 +267,16 @@ module Ione 
     | 
|
| 
       269 
267 
     | 
    
         
             
                      barrier.push(nil)
         
     | 
| 
       270 
268 
     | 
    
         
             
                      await { !reactor.running? }
         
     | 
| 
       271 
269 
     | 
    
         
             
                      reactor.on_error { calls << :pre_restarted }
         
     | 
| 
       272 
     | 
    
         
            -
                      calls.should  
     | 
| 
      
 270 
     | 
    
         
            +
                      calls.should eq([
         
     | 
| 
       273 
271 
     | 
    
         
             
                        :pre_started,
         
     | 
| 
       274 
272 
     | 
    
         
             
                        :post_started,
         
     | 
| 
       275 
273 
     | 
    
         
             
                        :pre_restarted,
         
     | 
| 
       276 
     | 
    
         
            -
                      ]
         
     | 
| 
      
 274 
     | 
    
         
            +
                      ])
         
     | 
| 
       277 
275 
     | 
    
         
             
                      reactor.start
         
     | 
| 
       278 
276 
     | 
    
         
             
                      reactor.on_error { calls << :post_restarted }
         
     | 
| 
       279 
277 
     | 
    
         
             
                      barrier.push(nil)
         
     | 
| 
       280 
278 
     | 
    
         
             
                      await { !reactor.running? }
         
     | 
| 
       281 
     | 
    
         
            -
                      calls.should  
     | 
| 
      
 279 
     | 
    
         
            +
                      calls.should eq([
         
     | 
| 
       282 
280 
     | 
    
         
             
                        :pre_started,
         
     | 
| 
       283 
281 
     | 
    
         
             
                        :post_started,
         
     | 
| 
       284 
282 
     | 
    
         
             
                        :pre_restarted,
         
     | 
| 
         @@ -286,7 +284,7 @@ module Ione 
     | 
|
| 
       286 
284 
     | 
    
         
             
                        :post_started,
         
     | 
| 
       287 
285 
     | 
    
         
             
                        :pre_restarted,
         
     | 
| 
       288 
286 
     | 
    
         
             
                        :post_restarted,
         
     | 
| 
       289 
     | 
    
         
            -
                      ]
         
     | 
| 
      
 287 
     | 
    
         
            +
                      ])
         
     | 
| 
       290 
288 
     | 
    
         
             
                    end
         
     | 
| 
       291 
289 
     | 
    
         
             
                  end
         
     | 
| 
       292 
290 
     | 
    
         | 
| 
         @@ -303,19 +301,19 @@ module Ione 
     | 
|
| 
       303 
301 
     | 
    
         
             
                    it 'returns a future that resolves to what the given block returns' do
         
     | 
| 
       304 
302 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       305 
303 
     | 
    
         
             
                      x = reactor.connect('example.com', 9999, 5) { :foo }.value
         
     | 
| 
       306 
     | 
    
         
            -
                      x.should  
     | 
| 
      
 304 
     | 
    
         
            +
                      x.should eq(:foo)
         
     | 
| 
       307 
305 
     | 
    
         
             
                    end
         
     | 
| 
       308 
306 
     | 
    
         | 
| 
       309 
307 
     | 
    
         
             
                    it 'defaults to 5 as the connection timeout' do
         
     | 
| 
       310 
308 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       311 
309 
     | 
    
         
             
                      connection = reactor.connect('example.com', 9999).value
         
     | 
| 
       312 
     | 
    
         
            -
                      connection.connection_timeout.should  
     | 
| 
      
 310 
     | 
    
         
            +
                      connection.connection_timeout.should eq(5)
         
     | 
| 
       313 
311 
     | 
    
         
             
                    end
         
     | 
| 
       314 
312 
     | 
    
         | 
| 
       315 
313 
     | 
    
         
             
                    it 'takes the connection timeout from the :timeout option' do
         
     | 
| 
       316 
314 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       317 
315 
     | 
    
         
             
                      connection = reactor.connect('example.com', 9999, timeout: 9).value
         
     | 
| 
       318 
     | 
    
         
            -
                      connection.connection_timeout.should  
     | 
| 
      
 316 
     | 
    
         
            +
                      connection.connection_timeout.should eq(9)
         
     | 
| 
       319 
317 
     | 
    
         
             
                    end
         
     | 
| 
       320 
318 
     | 
    
         | 
| 
       321 
319 
     | 
    
         
             
                    it 'returns the connection when no block is given' do
         
     | 
| 
         @@ -379,19 +377,19 @@ module Ione 
     | 
|
| 
       379 
377 
     | 
    
         
             
                    it 'returns a future that resolves to what the given block returns' do
         
     | 
| 
       380 
378 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       381 
379 
     | 
    
         
             
                      x = reactor.bind(ENV['SERVER_HOST'], port, 5) { |acceptor| :foo }.value
         
     | 
| 
       382 
     | 
    
         
            -
                      x.should  
     | 
| 
      
 380 
     | 
    
         
            +
                      x.should eq(:foo)
         
     | 
| 
       383 
381 
     | 
    
         
             
                    end
         
     | 
| 
       384 
382 
     | 
    
         | 
| 
       385 
383 
     | 
    
         
             
                    it 'defaults to a backlog of 5' do
         
     | 
| 
       386 
384 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       387 
385 
     | 
    
         
             
                      acceptor = reactor.bind(ENV['SERVER_HOST'], port).value
         
     | 
| 
       388 
     | 
    
         
            -
                      acceptor.backlog.should  
     | 
| 
      
 386 
     | 
    
         
            +
                      acceptor.backlog.should eq(5)
         
     | 
| 
       389 
387 
     | 
    
         
             
                    end
         
     | 
| 
       390 
388 
     | 
    
         | 
| 
       391 
389 
     | 
    
         
             
                    it 'takes the backlog from the :backlog option' do
         
     | 
| 
       392 
390 
     | 
    
         
             
                      reactor.start.value
         
     | 
| 
       393 
391 
     | 
    
         
             
                      acceptor = reactor.bind(ENV['SERVER_HOST'], port, backlog: 9).value
         
     | 
| 
       394 
     | 
    
         
            -
                      acceptor.backlog.should  
     | 
| 
      
 392 
     | 
    
         
            +
                      acceptor.backlog.should eq(9)
         
     | 
| 
       395 
393 
     | 
    
         
             
                    end
         
     | 
| 
       396 
394 
     | 
    
         | 
| 
       397 
395 
     | 
    
         
             
                    it 'returns the acceptor when no block is given' do
         
     | 
| 
         @@ -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,  
     | 
| 
      
 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  
     | 
| 
       84 
     | 
    
         
            -
                        accepted_handlers.first.port.should  
     | 
| 
      
 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  
     | 
| 
      
 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  
     | 
| 
      
 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  
     | 
| 
      
 152 
     | 
    
         
            +
                        read_sizes.drop(1).should eq([3, 2, 1])
         
     | 
| 
       153 
153 
     | 
    
         
             
                      end
         
     | 
| 
       154 
154 
     | 
    
         
             
                    end
         
     | 
| 
       155 
155 
     | 
    
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    
    
        data/spec/support/fake_server.rb
    CHANGED
    
    
    
        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.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Theo Hultberg
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-10-26 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
         
     | 
| 
         @@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       70 
70 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       71 
71 
     | 
    
         
             
            requirements: []
         
     | 
| 
       72 
72 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       73 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 73 
     | 
    
         
            +
            rubygems_version: 2.4.5
         
     | 
| 
       74 
74 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       75 
75 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       76 
76 
     | 
    
         
             
            summary: Reactive programming framework for Ruby
         
     |