forked from eventmachine/eventmachine
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check that the passed connection handler is of the proper class (subc…
…lass of EM::Connection), and added test for this. Signed-off-by: Aman Gupta <[email protected]>
- Loading branch information
1 parent
1197a08
commit 9b4ef82
Showing
2 changed files
with
44 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
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 @@ | ||
$:.unshift "../lib" | ||
require 'eventmachine' | ||
require 'test/unit' | ||
|
||
class TestHandlerCheck < Test::Unit::TestCase | ||
|
||
class Foo < EM::Connection; end; | ||
module TestModule; end; | ||
|
||
def test_with_correct_class | ||
assert_nothing_raised do | ||
EM.run { | ||
EM.connect("127.0.0.1", 80, Foo) | ||
EM.stop_event_loop | ||
} | ||
end | ||
end | ||
|
||
def test_with_incorrect_class | ||
assert_raise(ArgumentError) do | ||
EM.run { | ||
EM.connect("127.0.0.1", 80, String) | ||
EM.stop_event_loop | ||
} | ||
end | ||
end | ||
|
||
def test_with_module | ||
assert_nothing_raised do | ||
EM.run { | ||
EM.connect("127.0.0.1", 80, TestModule) | ||
EM.stop_event_loop | ||
} | ||
end | ||
end | ||
|
||
end |