Sha256: aa40f71c272acc6a0f17a21ded9a09a0b1e440ed8cd7179536b63f0e8f904d8a

Contents?: true

Size: 906 Bytes

Versions: 10

Compression:

Stored size: 906 Bytes

Contents

require 'jellyfish/test'

# stolen from sinatra
describe 'Sinatra streaming_test.rb' do
  paste :jellyfish

  would 'return the concatinated body' do
    app = Class.new{
      include Jellyfish
      get '/' do
        Jellyfish::ChunkedBody.new{ |out|
          out['Hello']
          out[' ']
          out['World!']
        }
      end
    }.new
    _, _, body = get('/', app)
    body.to_a.join.should.eq 'Hello World!'
  end

  would 'postpone body generation' do
    stream = Jellyfish::ChunkedBody.new{ |out|
      10.times{ |i| out[i] }
    }

    stream.each.with_index do |s, i|
      s.should.eq i
    end
  end

  would 'give access to route specific params' do
    app = Class.new{
      include Jellyfish
      get(%r{/(?<name>\w+)}){ |m|
        Jellyfish::ChunkedBody.new{ |o| o[m[:name]] }
      }
    }.new
    _, _, body = get('/foo', app)
    body.to_a.join.should.eq 'foo'
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jellyfish-1.4.0 test/sinatra/test_chunked_body.rb
jellyfish-1.3.1 test/sinatra/test_chunked_body.rb
jellyfish-1.3.0 test/sinatra/test_chunked_body.rb
jellyfish-1.2.2 test/sinatra/test_chunked_body.rb
jellyfish-1.2.1 test/sinatra/test_chunked_body.rb
jellyfish-1.2.0 test/sinatra/test_chunked_body.rb
jellyfish-1.1.1 test/sinatra/test_chunked_body.rb
jellyfish-1.1.0 test/sinatra/test_chunked_body.rb
jellyfish-1.0.2 test/sinatra/test_chunked_body.rb
jellyfish-1.0.1 test/sinatra/test_chunked_body.rb