6. XML REST API JSON REST API
you generate TwiML they host a JVM script
just phone and SMS IM and Twitter integration
1¢/2¢ per minute 3¢ per minute
$1 per month per line $3 per month per line
16. For a good time call (540) 318-2266
post '/' do
return Twilio::Verb.new do |v|
v.say "Welcome to the party!"
v.dial do
v.conference 'rubynation_partyline'
end
end.response
end
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Welcome to the party!</Say>
<Dial>
<Conference>rubynation_partyline</Conference>
</Dial>
</Response>
20. WHOOPS! RAILS ISSUES
• skip_before_filter :verify_authenticity_token
• be careful about response types (use *.xml or filter)
• tough to fit in RESTful model
30. require 'rubygems'
require 'sinatra'
class FakeTwilio < Sinatra::Base
def fixture(resource)
resource.gsub!('/', '-')
Rails.root.join('test', 'support', 'twilio_responses',
"#{resource}-GET.xml").read
end
get '/2010-04-01/Accounts/:sid/*' do |sid, resource|
fixture(resource)
end
post '/2010-04-01/Accounts/:sid/*' do |sid, resource|
fixture(resource)
end
end
Artifice.activate_with(FakeTwilio)
31. ARTIFICE + CUCUMBER
Kinda sucked. got better?
module Selenium
Net = ::Net.dup
module Net
HTTP = Artifice::NET_HTTP
end
end
class Capybara::Server
Net = ::Net.dup
module Net
HTTP = Artifice::NET_HTTP
end
end
32. TWIML TESTING
test "new should omit connected connections" do
@connection.connect!
post :new, :CallSid => @sid
assert_match "Number", response.body
assert_not_match @connection.number, response.body
end
Basic match testing