Test mode not catching requests when using Cucumber

78 views
Skip to first unread message

Ben H

unread,
Jan 12, 2012, 1:01:02 AM1/12/12
to omniauth
I am trying to test my OmniAuth login process by providing a faked
authentication hash when a request is made to /auth/facebook, as
described at https://github.com/intridea/omniauth/wiki/Integration-Testing.
The problem is, when I turn test mode on, the request returns as an
error, which is the same behaviour as when test mode is not turned on.

user_management.feature
Feature: User management
@omniauth_test
Scenario: Login
Given a user exists
And that user is signed in

web_steps.rb
...
And /^that user is signed in$/ do
visit "/auth/facebook"
end
...

omniauth.rb
Before('@omniauth_test') do
OmniAuth.config.test_mode = true
p "OmniAuth.config.test_mode is #{OmniAuth.config.test_mode}"
# the symbol passed to mock_auth is the same as the name of the
provider set up in the initializer
OmniAuth.config.mock_auth[:facebook] = {
"provider"=>"facebook",
"uid"=>"uid",
"user_info"=>{"email"=>"te...@xxxx.com", "first_name"=>"Test",
"last_name"=>"User", "name"=>"Test User"}
}
end

After('@omniauth_test') do
OmniAuth.config.test_mode = false
end

Outcome
Feature: User management

@omniauth_test
Scenario: Login # features/user_management.feature:3
"OmniAuth.config.test_mode is true"
Given a user exists # features/step_definitions/
pickle_steps.rb:4
And that user is signed in # features/step_definitions/
web_steps.rb:40
No route matches [GET] "/auth/
facebook" (ActionController::RoutingError)
./features/step_definitions/web_steps.rb:41:in `/^that user is
signed in$/'
features/testing.feature:5:in `And that user is signed in'

chasselschwert

unread,
Feb 23, 2012, 12:10:54 PM2/23/12
to omniauth
I am having a similar problem using omniauth-identity. My test fails
with `No route matches [POST] "/auth/identity/
register" (ActionController::RoutingError)` when trying to visit the
route for creating a new identity. It works fine with manual testing.
Have you made any progress with this?

On Jan 12, 1:01 am, Ben H <crusa...@gmail.com> wrote:
> I am trying to test my OmniAuth login process by providing a faked
> authentication hash when a request is made to /auth/facebook, as
> described athttps://github.com/intridea/omniauth/wiki/Integration-Testing.
> The problem is, when I turn test mode on, the request returns as an
> error, which is the same behaviour as when test mode is not turned on.
>
> user_management.feature
> Feature: User management
>     @omniauth_test
>     Scenario: Login
>         Given a user exists
>         And that user is signed in
>
> web_steps.rb
> ...
> And /^that user is signed in$/ do
>   visit "/auth/facebook"
> end
> ...
>
> omniauth.rb
> Before('@omniauth_test') do
>   OmniAuth.config.test_mode = true
>   p "OmniAuth.config.test_mode is #{OmniAuth.config.test_mode}"
>   # the symbol passed to mock_auth is the same as the name of the
> provider set up in the initializer
>   OmniAuth.config.mock_auth[:facebook] = {
>       "provider"=>"facebook",
>       "uid"=>"uid",
>       "user_info"=>{"email"=>"t...@xxxx.com", "first_name"=>"Test",

Aaron Marks

unread,
Dec 25, 2013, 10:49:19 PM12/25/13
to omni...@googlegroups.com
Did you guys ever figure out a solution for this? I am running into the same issue.
Reply all
Reply to author
Forward
0 new messages