且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Rspec Rails 3.1 集成测试.如何发送移动、http 基本身份验证和 JSON 的 post 请求标头?

更新时间:2021-07-20 15:39:51

我想出了我需要做什么

post("scores", {:score => {:mobile_user_id => @mobile_user.id, :points => 50, :time_taken => 7275}}.to_json,
       {"HTTP_USER_AGENT" => "Mobile", 'HTTP_AUTHORIZATION' => get_basic_auth, 'HTTP_CONTENT_TYPE' => "application/json"}

显然不需要移动"用户代理来测试普通的 json 请求.

Obviously the "mobile" user agent is not needed to test normal json requests.

希望对某人有帮助