22.09.2013 Views

Ruby on rails 101 - Peter Marklund's Home

Ruby on rails 101 - Peter Marklund's Home

Ruby on rails 101 - Peter Marklund's Home

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Mocha and Stubba<br />

Examples<br />

client = Goyada::HttpClient.new({})<br />

client.expects(:http_timeout).returns(0.01)<br />

client.expects(:get_c<strong>on</strong>necti<strong>on</strong>).returns(lambda { sleep 10 })<br />

resp<strong>on</strong>se = client.send(:https_resp<strong>on</strong>se, "http://www.test.com", nil, nil)<br />

assert_equal(client.send(:error_resp<strong>on</strong>se).code, resp<strong>on</strong>se.code)<br />

assert_equal(Timeout::Error, resp<strong>on</strong>se.excepti<strong>on</strong>.class)<br />

::HttpClient.expects(:get_iso8859).with(http_url).returns("a piece of text")<br />

get :read, :dtmf => 3<br />

assert_resp<strong>on</strong>se :success<br />

assert_vxml "prompt", /a piece of text/<br />

163

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!