2012-11-22 82 views
0

我使用Calabsh來測試iOS應用程序。在測試期間,我需要創建POST請求來更改某些值,然後驗證更改是否反映在UI中。使用Ruby和Calabash的POST請求

請求看起來像:

wwww.testserver.com/userAddMoney?user_id=1 &量= 999

要授權服務器上我需要通過特殊的參數到報頭的請求:

頭:X-測試認證 - 揭祕:kI7wGju76kjhJHGklk76

回答

1
require 'net/http' 

uri = URI.parse('http://www.testserver.com/userAddMoney?user_id=1&amount=999') 
http = Net::HTTP.new(uri.host,uri.port) 
## https.use_ssl = true # use https, need require net/https 
req = Net::HTTP::Post.new(uri.path) 
req['X-Testing-Auth-Secret'] = 'kI7wGju76kjhJHGklk76' 
res = http.request(req) 

文檔瀏覽:Net::HTTP::PostNet::HTTPSession

+0

非常感謝! – z3us