Sha256: d761d8a0b9bf69737e4287ebb1c79b884b4ef10395ffe4ad5b0dc4bd080e1109

Contents?: true

Size: 682 Bytes

Versions: 24

Compression:

Stored size: 682 Bytes

Contents

require File.expand_path("helper", File.dirname(__FILE__))

class Shrimp
  def initialize(app)
    @app = app
  end

  def call(env)
    status, headers, resp = @app.call(env)

    arr = []
    resp.each { |e| arr << e }

    [status, headers, arr.reverse]
  end
end

test do
  class API < Cuba
    use Shrimp

    define do
      on "v1/test" do
        res.write "OK"
        res.write "1"
        res.write "2"
      end
    end
  end

  Cuba.define do
    on "api" do
      run API
    end
  end

  _, _, body = Cuba.call({ "PATH_INFO" => "/api/v1/test", "SCRIPT_NAME" => "/" })

  arr = []

  body.each do |line|
    arr << line
  end

  assert_equal ["2", "1", "OK"], arr
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
cuba-4.0.1 test/middleware.rb
cuba-4.0.0 test/middleware.rb
cuba-3.9.3 test/middleware.rb
cuba-3.9.2 test/middleware.rb
cuba-3.9.1 test/middleware.rb
cuba-3.9.0 test/middleware.rb
cuba-3.8.1 test/middleware.rb
cuba-3.8.0 test/middleware.rb
cuba-3.7.0 test/middleware.rb
cuba-3.6.0 test/middleware.rb
cuba-3.5.0 test/middleware.rb
cuba-3.4.0 test/middleware.rb
cuba-3.3.0 test/middleware.rb
cuba-3.2.0 test/middleware.rb
cuba-3.1.1 test/middleware.rb
cuba-3.1.0 test/middleware.rb
cuba-3.1.0.rc2 test/middleware.rb
cuba-3.1.0.rc1 test/middleware.rb
cuba-3.0.1.rc2 test/middleware.rb
cuba-3.0.1.rc1 test/middleware.rb