測試我的集成測試是這樣的:Rails的整合與法拉第Omniauth
class OAuthTest < ActionDispatch::IntegrationTest
...
@client = OAuth2::Client.new(
client_id,
client_secret,
{ :site => 'https://provider', :token_url => '/oauth/access_token' }
)
@client.connection.build do |b|
b.adapter :action_dispatch, self
end
access_token = @client.auth_code.get_token(...)
access_token.get("/user.json")
並與法拉第0.7.6它工作得很好,在action_dispatch
適配器將路由HTTP請求到我的Rails應用程序(調用users_controller
)。但法拉第0.8.0的action_dispatch
適配器被替換爲rack
(見https://github.com/technoweenie/faraday/pull/134),我無法使它工作。
我想我需要將上面的代碼改成這樣:
@client.connection.build do |b|
b.adapter :rack, self.app
end
但它在機架(1.2.5)期待一個流失敗,但它得到一個Hash和線149說undefined read method for Hash
(這裏:https://github.com/rack/rack/blob/1.2.5/lib/rack/request.rb#L149)。
我該如何做這項工作?
哇,這個工程!非常感謝你!!! – 2012-07-24 08:53:24