【发布时间】:2012-04-26 12:42:05
【问题描述】:
我的集成测试如下所示:
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")
在 Faraday 0.7.6 中它工作得很好,action_dispatch 适配器会将 http 请求路由到我的 Rails 应用程序(调用 users_controller)。但是在 Faraday 0.8.0 中,action_dispatch 适配器被rack(参见https://github.com/technoweenie/faraday/pull/134)取代,我无法让它工作。
我想我需要把上面的代码改成这样:
@client.connection.build do |b|
b.adapter :rack, self.app
end
但它在 Rack (1.2.5) 期待 Stream 时失败,但它得到一个哈希并在第 149 行显示undefined read method for Hash(此处为:https://github.com/rack/rack/blob/1.2.5/lib/rack/request.rb#L149)。
我怎样才能做到这一点?
【问题讨论】:
标签: ruby-on-rails ruby oauth oauth-2.0 faraday