forked from lifo/cramp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Long polling test
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'test_helper' | ||
|
||
class LongPollingTest < Cramp::TestCase | ||
|
||
class PollController < Cramp::Action | ||
self.transport = :long_polling | ||
|
||
on_start :foot_long_pole | ||
on_finish :poll_done | ||
|
||
def foot_long_pole | ||
render "Hello World" | ||
end | ||
|
||
cattr_accessor :logs | ||
self.logs = [] | ||
def poll_done | ||
self.logs << 'Poll done' | ||
end | ||
end | ||
|
||
def app | ||
PollController | ||
end | ||
|
||
def test_body | ||
get_body '/' do |body| | ||
assert_equal 'Hello World', body | ||
stop | ||
end | ||
end | ||
|
||
def test_render_finishes_response | ||
get('/') { EM.next_tick { stop } } | ||
assert_equal 'Poll done', PollController.logs[0] | ||
end | ||
end |