David Tuite
David Tuite

Reputation: 22663

"Not Found" when testing omniauth Facebook authentication with Capybara

I have a facebook Omniauth authentication system implemented in my project. I works fine for me in the browser and up until today I had a full set of integration tests written and passing using Capybara.

Today though, I ran the test suite and all the related tests fail.

The problem stems from this helper module which is used in pretty much all the tests to simulate facebook (or otherwise) authentication:

module IntegrationSpecHelper
  def login_with_oauth service
    visit "/auth/#{service}"
    save_and_open_page
  end
end

This doesn't seem to work any more, even though it did 2 days ago, and still works on my development server. The "save_and_open_page" displays a page which literally contains the line "Not Found" and nothing else.

Anyone know what would cause this?

Upvotes: 0

Views: 554

Answers (2)

AsemRadhwi
AsemRadhwi

Reputation: 887

In rails 3, you can put each omniauth config initializer in the respective environment file in the config/environments folder i.e. development.rb, test.rb, and production.rb

Upvotes: 0

David Tuite
David Tuite

Reputation: 22663

Figured this out myself in the end.

Basically I was setting my auth providers based on environment in my omniauth config initializer. I has this setup:

  if Rails.env.production?
    provider :facebook, ...
    provider :twitter, ...
  elsif Rails.env.development?
    provider :facebook, ...
    provider :twitter, ...
  end

As you can see I forgot to provide a settings for the test environment hence all my tests were failing.

Upvotes: 2

Related Questions