如何在集成测试(Rails)中包含http标头?

时间:2016-01-23 10:51:26

标签: ruby-on-rails ruby-on-rails-4 testing http-headers integration-testing

我正在尝试为我的API编写集成测试。提出的请求是:

$('body').on('click', "ul#pilots li", function () {
    var t = $(this).text(); $.cookie("pilot", t);
    ("#pilot_txt").text(t);
})

但请求中还应包含http标头:

delete sessions_path, session: { article_id: @article.id}

如何包含这些http标头?

1 个答案:

答案 0 :(得分:1)

这个怎么样:

delete sessions_path, {session: { article_id: @article.id}}, {"Authorization" => "mytoken", "My_email" => @user.email}

您可以查看此answer以获取更多信息。