Skip to content

Commit

Permalink
Test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kyledrake committed Apr 18, 2011
0 parents commit 4541d03
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm use 1.9.2@rack_fiber_pool_test_app --create
11 changes: 11 additions & 0 deletions Gemfile
@@ -0,0 +1,11 @@
source :rubygems
gem 'rack'
gem 'rack-fiber_pool', :require => 'rack/fiber_pool'
gem 'eventmachine'
gem 'em-http-request'
gem 'em-synchrony'
gem 'thin'

group :test do
gem 'rack-test', :require => 'rack/test'
end
33 changes: 33 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,33 @@
GEM
remote: http://rubygems.org/
specs:
addressable (2.2.4)
daemons (1.1.2)
em-http-request (0.3.0)
addressable (>= 2.0.0)
escape_utils
eventmachine (>= 0.12.9)
em-synchrony (0.2.0)
eventmachine (>= 0.12.9)
escape_utils (0.2.3)
eventmachine (0.12.10)
rack (1.2.2)
rack-fiber_pool (0.9.1)
rack-test (0.5.6)
rack (>= 1.0)
thin (1.2.11)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)

PLATFORMS
ruby

DEPENDENCIES
em-http-request
em-synchrony
eventmachine
rack
rack-fiber_pool
rack-test
thin
3 changes: 3 additions & 0 deletions config.ru
@@ -0,0 +1,3 @@
require './test_app.rb'
use Rack::FiberPool
run TestApp
16 changes: 16 additions & 0 deletions test.rb
@@ -0,0 +1,16 @@
require './test_app.rb'
Bundler.require :test
require 'minitest/autorun'

describe TestApp do
include Rack::Test::Methods
def app; TestApp end

describe 'any request' do
it 'returns google.com with EM' do
get '/get_google'
last_response.status.must_equal 200
(last_response.body.length > 0).must_equal true
end
end
end
9 changes: 9 additions & 0 deletions test_app.rb
@@ -0,0 +1,9 @@
Bundler.setup
Bundler.require

class TestApp
def self.call(env)
result = EM::Synchrony.sync EventMachine::HttpRequest.new('http://google.com').get
[200, {"Content-Type" => "text/html"}, [result.response]]
end
end

0 comments on commit 4541d03

Please sign in to comment.