I am facing an error trying to configure omniauth for integration testing purpose with cucumber (I set up Omniauth through Devise as the wiki provides)
Please see below:
Scenario: Test # features/omniauth.feature:3
Given I am signed in with facebook # features/step_definitions/omniauth_steps.rb:1
bad component(expected host component): http://www.example.com (URI::InvalidComponentError)
/Users/benoit/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/uri/generic.rb:395:in `check_host'
/Users/benoit/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/uri/generic.rb:409:in `host='
./features/step_definitions/omniauth_steps.rb:2:in `/^I am signed in with facebook$/'
features/omniauth.feature:4:in `Given I am signed in with facebook'
Then I open the page # features/step_definitions/debug_steps.rb:5
Here are my files:
Feature: OmniAuth
Scenario: Test
Given I am signed in with facebook
Then I open the page
Given /^I am signed in with facebook$/ do
visit "/auth/facebook"
end
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:facebook] = {
'uid' => '12345',
"user_info" => {
"email" => "[email protected]",
"first_name" => "foo",
"last_name" => "Bar"
}
}
case
when Rails.env.production?
config.omniauth :facebook, 'XXXX', 'XXXX',
{:scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
when Rails.env.development?
config.omniauth :facebook, 'XXXX', 'XXXX'
when Rails.env.test?
config.omniauth :facebook, 'XXXX', 'XXXX'
OmniAuth.config.full_host = 'http://example.com' # issue 257
end
(Reference: issue 257)
devise_scope :user do
get '/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
devise_for :users, :path => "", :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
As info, I also configured my facebook test_app with the following URL: http://example.com/
I would be pleased to know if someone has a thought/experienced this. Thank you!
try to add :
Before do
Capybara.default_host = 'example.com'
end
to your support/env.rb file, try also commenting out :
OmniAuth.config.full_host = 'http://example.com' # issue 257
from your initializer/devise.rb file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With