Created
March 9, 2011 08:32
-
-
Save PatrickLef/861886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'rubygems' | |
gem 'sinatra', :version => "1.2.0" | |
require 'sinatra' | |
require 'mysql2/em' | |
gem "async_sinatra", :version => "0.5.0" | |
require 'sinatra/async' | |
require "sinatra/async/test" | |
require 'test/unit' | |
require 'rack/test' | |
class MyApp < Sinatra::Base | |
register Sinatra::Async | |
aget ('/') do | |
# client = Mysql2::EM::Client.new | |
#client.query("SELECT sleep(1)").callback do |result| | |
# body "fisk" | |
# end | |
body "fisk" | |
end | |
end | |
class MyAppTest < Test::Unit::TestCase | |
include Rack::Test::Methods | |
include Sinatra::Async::Test::Methods | |
def app | |
MyApp | |
end | |
def test_my_default | |
#client = Mysql2::EM::Client.new | |
#client.query("SELECT sleep(1)").callback do |result| | |
# EventMachine.stop | |
#end | |
get '/' | |
async_continue | |
p last_response.body | |
assert_equal 'Hello World!', last_response.body | |
end | |
end | |
#MyApp.run! | |
# include EM::Deferrable | |
# set_deferred_status :succeeded |
Author
PatrickLef
commented
Aug 28, 2012
Sorry for my late reply. I did an ugly monkeypatch for this when I was
experimenting with this. I would have hoped that they had fixed this by now.
Well here is my solution: https://gist.github.com/861886#comments
Cheers
On Fri, Jul 20, 2012 at 2:01 PM, Joseph Phillips < ***@***.*** > wrote:
I know this is a while back now, but did you find a resolution to the
issue this code produces?
I've encountered the same thing, and I'm having trouble figuring it out:
"undefined method 'async_schedules' for ..."
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/861886
##
//Mvh Patrick Lef - Hamsterpaj.net
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment