-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from gaffneyc/master
Improvements to LineProtocol and have it autoload.
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 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
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,33 @@ | ||
require 'em_test_helper' | ||
|
||
class TestLineProtocol < Test::Unit::TestCase | ||
class LineProtocolTestClass | ||
include EM::Protocols::LineProtocol | ||
|
||
def lines | ||
@lines ||= [] | ||
end | ||
|
||
def receive_line(line) | ||
lines << line | ||
end | ||
end | ||
|
||
def setup | ||
@proto = LineProtocolTestClass.new | ||
end | ||
|
||
def test_simple_split_line | ||
@proto.receive_data("this is") | ||
assert_equal([], @proto.lines) | ||
|
||
@proto.receive_data(" a test\n") | ||
assert_equal(["this is a test"], @proto.lines) | ||
end | ||
|
||
def test_simple_lines | ||
@proto.receive_data("aaa\nbbb\r\nccc\nddd") | ||
assert_equal(%w(aaa bbb ccc), @proto.lines) | ||
end | ||
|
||
end |