2014-06-18 72 views
3

自定義標題PARAMS我用葡萄API和我需要編寫自定義頁眉測試廣東話設置使用RSpec和葡萄

我的代碼:

it "should accept message" do 
    post "/api/v1/my/route", post_data, secret: "ASDFGHJKL" 
    last_response.status.should == 201 
    end 

但路線得不到頭可言, 我也試過headers['secret'] = "ASDFGHJKL"request.env['secret'] 沒有用。

我該如何將rspec中的標題傳遞給葡萄路線?

回答

0

嘗試使用@request變量,例如, @request.env['secret'] = 'ASDF..'。希望這可以幫助。

而且,看看這個 - Sending custom headers through RSpec

+0

'@ request'是零,而在其他線程不工作的所有解決方案... – Dima