2016-12-21 16 views
0

私はRESTfulなAPIのためのラッパーの宝石を作成しています。私はdocumentationあたりとしてhashieミドルウェアを追加しようとすると、私は次のエラーを取得しています:ここでファラデー::エラー::ハリーはファラデー::ミドルウェアに登録されていません

Magpress::Login::#call#test_0001_should return valid JWT token: 
Faraday::Error: :hashie is not registered on Faraday::Middleware 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday.rb:184:in `lookup_middleware' 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday/rack_builder.rb:204:in `use_symbol' 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday/rack_builder.rb:84:in `use' 
    /home/amit/projects/bt/magpress/lib/magpress/client.rb:24:in `block in connection' 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday/connection.rb:91:in `initialize' 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday.rb:70:in `new' 
    /home/amit/.rvm/gems/[email protected]/gems/faraday-0.10.0/lib/faraday.rb:70:in `new' 
    /home/amit/projects/bt/magpress/lib/magpress/client.rb:18:in `connection' 
    /home/amit/projects/bt/magpress/lib/magpress/base.rb:7:in `initialize' 
    /home/amit/projects/bt/magpress/test/login_spec.rb:13:in `new' 
    /home/amit/projects/bt/magpress/test/login_spec.rb:13:in `block (3 levels) in <top (required)>' 

は、私が.gemspecに依存関係をdelcared方法です。

... 
    spec.add_dependency "faraday" 
    spec.add_dependency "faraday_middleware" 
    spec.add_dependency "hashie" 
.... 

とファラデーを使用し、それがここで間違っている可能性が何

require 'faraday' 
require 'faraday_middleware' 
require 'hashie' 
module Magpress 
    class Client 
    def connection(url) 
     conn = ::Faraday.new(url) do |faraday| 
     faraday.request :json 

     faraday.response :json, :content_type => /\bjson$/ 

     # faraday.use :instrumentation 
     faraday.use :hashie # FaradayMiddleware::Mashify 
     faraday.adapter Faraday.default_adapter 
     end 
     conn 
    end 
    end 
end 

ファラデーとmiddlware宝石のバージョン

[email protected]:~/projects/bt/magpress$ gem list | grep faraday 
faraday (0.10.0) 
faraday_middleware (0.10.1) 

ミドルウェアのクラス?

私はFaradayMiddleware::Mashify:hashieを交換した場合、エラーが離れて行くが、バニラHash代わりの Hashie::Mash

+1

'require 'hashie''? – mudasobwa

+0

それも試してみました。 –

答えて

0

出来上がりのresponse.bodyを返すインスタンス!これは修正されています。修正

faraday.response :mashify 
faraday.response :json, :content_type => /\bjson$/ 

現在

faraday.response :json, :content_type !=> /\bjson$/ 
faraday.use :hashie # FaradayMiddleware::Mashify 

私はthe codeを読むことによって修正することができます!

関連する問題