Permalink
Browse files

Add support for the 'Play' TwiML verb.

  • Loading branch information...
1 parent 14958ff commit 4f2d50e1c67b8fb865b032a6e752200c5c7a4b8e Jon Gilbraith committed Feb 26, 2013
View
@@ -34,13 +34,13 @@ What's supported
TTT supports most of the more common Twilio scenarios:
* Checking for Say elements and their content
+* Checking for Play elements and their content
* Taking action on Gather elements and querying their contents
* Following and querying redirects
* Dial and Hangup
TTT doesn't yet support (but you should contribute them!)
-* Play
* Queue
* Any of the other conference calling features
@@ -31,6 +31,15 @@ def has_say?(say)
return false
end
+ # Stuff for Plays
+ def has_play?(play)
+ @xml.xpath("Play").each do |s|
+ return true if s.inner_text == play
+ end
+
+ return false
+ end
+
# Stuff for Dials
def has_dial?(number)
@xml.xpath("Dial").each do |s|
@@ -0,0 +1 @@
+<Play>/path/to/an/audio/clip.mp3</Play>
@@ -8,5 +8,6 @@
post "test_dial", :on => :collection
post "test_redirect", :on => :collection
post "test_say", :on => :collection
- end
+ post "test_play", :on => :collection
+ end
end
@@ -124,6 +124,22 @@
end
end
+ describe "play" do
+ before(:each) do
+ @call = ttt_call(test_play_twilio_index_path, @our_number, @their_number)
+ end
+
+ it "should have the expected say play methods" do
+ @call.should respond_to(:has_play?)
+ end
+
+ it "should have the right values for has_say?" do
+ @call.has_play?("/path/to/a/different/audio/clip.mp3").should be_false
+ @call.has_play?("/path/to/an/audio/clip.mp3").should be_true
+ @call.has_play?("clip.mp3").should be_false
+ end
+ end
+
describe "dial" do
before(:each) do
@call = ttt_call(test_dial_twilio_index_path, @our_number, @their_number)

0 comments on commit 4f2d50e

Please sign in to comment.