2013-12-09 59 views
2

我一直試圖用RSpec測試OmniAuth,但它還沒有奏效。嘗試使用RSpec測試OmniAuth時出現「Real HTTP connections is disabled」錯誤

spec_helper.rb

OmniAuth.config.test_mode = true 
OmniAuth.config.add_mock(:twitter, {:uid => '12345'}) 

spec/requests/static_pages_spec.rb

describe "for signed-in users" do 
    before do 
    visit "auth/twitter" 
    end 
    it { should have_content("Log out") } 
end 

,我得到以下錯誤。

Failure/Error: visit "auth/twitter" 
ActionView::Template::Error: 
    Real HTTP connections are disabled. Unregistered request: 

根據官方文檔auth/twitter的請求,應重定向到auth/twitter/callback。爲什麼它嘗試使用HTTP連接?

我讀過以下網頁和問題,但我找不到爲什麼測試失敗。

http://blog.zerosum.org/2011/03/19/easy-rails-outh-integration-testing.html https://github.com/intridea/omniauth/wiki/Integration-Testing omniauth-facebook and testing with rspec http://blog.plataformatec.com.br/2010/12/acceptance-tests-for-omniauth/

+0

你有webmock安裝? – dfedde

回答

相關問題