"Real HTTP connections are disabled" error when trying test OmniAuth with RSpec

Viewed 15276

I've been trying to test OmniAuth with RSpec, but yet it have not worked.

In spec_helper.rb

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

and in 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

And I get following error.

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

According to the official document a request to auth/twitter should be redirect to auth/twitter/callback. Why does it try to have HTTP connection?

I've read following web pages and questions, but I couldn't find why the test failed.

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/

1 Answers
Related