-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
9 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
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,47 @@ | ||
module Acli | ||
class TestCommands < MTest::Unit::TestCase | ||
class TestClient | ||
attr_reader :identifier | ||
|
||
def initialize(identifier = "test") | ||
@identifier = identifier | ||
end | ||
|
||
def close | ||
@closed = true | ||
end | ||
|
||
def closed? | ||
@closed == true | ||
end | ||
end | ||
|
||
def client | ||
@client ||= TestClient.new | ||
end | ||
|
||
def test_quit | ||
subject = Commands.new(client) | ||
subject.prepare_command "\\q" | ||
assert client.closed? | ||
end | ||
|
||
def test_subscribe | ||
subject = Commands.new(client) | ||
assert_equal( | ||
"{\"command\":\"subscribe\",\"identifier\":\"{\\\"id\\\":2,\\\"channel\\\":\\\"chat\\\"}\"}", | ||
subject.prepare_command("\\s chat id:2") | ||
) | ||
end | ||
|
||
def test_perform | ||
subject = Commands.new(client) | ||
assert_equal( | ||
"{\"command\":\"message\",\"identifier\":\"test\",\"data\":\"{\\\"message\\\":\\\"Hello!\\\",\\\"sid\\\":123,\\\"action\\\":\\\"speak\\\"}\"}", | ||
subject.prepare_command("\\p speak message:\"Hello!\" sid:123") | ||
) | ||
end | ||
end | ||
end | ||
|
||
MTest::Unit.new.run |