-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final (almost) version of AMI client
- Loading branch information
Showing
6 changed files
with
214 additions
and
111 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,35 @@ | ||
require "./spec_helper" | ||
|
||
describe Asterisk::AMI do | ||
# Testing basic actions | ||
describe "#on_hooks" do | ||
it "should trigger 'FullyBooted' callback" do | ||
# can't use with_ami wrapper: FullyBooted aproaching next after login | ||
ami = Asterisk::AMI.new username: "asterisk.cr", secret: "asterisk.cr" | ||
|
||
ami.on_event("FullyBooted") do |ami, event| | ||
event.event.should eq("FullyBooted") | ||
event["status"].should match /Fully Booted/i | ||
# runner already processed "FullyBooted" and ami.connected? expected to | ||
# be true | ||
# pp ami | ||
# ami.connected?.should be_true | ||
end | ||
|
||
ami.login | ||
# callback will be triggered by AMI right after login action | ||
sleep 0.2 | ||
ami.logoff | ||
end | ||
|
||
it "should trigger 'on_close' callback" do | ||
with_ami do |ami| | ||
ami.on_close do |ami| | ||
# AMI connection should be closed already | ||
ami.connected?.should be_false | ||
end | ||
end | ||
end | ||
|
||
end | ||
end |
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
Oops, something went wrong.