Reputation: 869
I am looking for help testing omniauth authentication with cucumber. I have tried following a tutorial (http://samuelmullen.com/2011/05/simple-integration-testing-with-cucumber-and-omniauth/), but it doesn't seem to be calling the session controller at all.
Here is what I have so far:
features/support/env.rb:
Capybara.default_host = 'example.org'
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:twitter, {
:uid => '12345',
:info => {
:name => 'twitteruser',
}
})
OmniAuth.config.add_mock(:facebook, {
:uid => '12345',
:info => {
:name => 'facebookuser'
}
})
step definition:
Given /^I am signed in with provider "(.*)"$/ do |provider|
visit "/auth/#{provider.downcase}"
end
scenario:
Scenario: a user can log into facebook
Given I am signed in with provider "facebook"
And I am on the profile page for "facebookuser"
Then I should see "facebookuser"
Any clue why this isn't working? :/. Thank you!
Upvotes: 1
Views: 1199
Reputation: 869
Changed contents of env.rb to this and now works.
Before('@omniauth_test') do
OmniAuth.config.test_mode = true
Capybara.default_host = 'http://example.com'
OmniAuth.config.add_mock(:twitter, {
:uid => '12345',
:info => {
:name => 'twitteruser',
}
})
OmniAuth.config.add_mock(:facebook, {
:uid => '12345',
:info => {
:name => 'facebookuser'
}
})
end
After('@omniauth_test') do
OmniAuth.config.test_mode = false
end
Upvotes: 5