@@ -69,8 +69,10 @@ class MyLdapProvider < OmniAuth::Strategies::LDAP; end
6969
7070 it 'should redirect to error page' do
7171 post ( '/auth/ldap/callback' , { :username => 'ping' , :password => 'password' } )
72- last_response . should be_redirect
73- last_response . headers [ 'Location' ] . should =~ %r{invalid_credentials}
72+
73+ expect ( last_response ) . to be_redirect
74+ expect ( last_response . headers [ 'Location' ] ) . to match ( 'invalid_credentials' )
75+ expect ( last_request . env [ 'omniauth.error' ] . message ) . to eq ( 'Invalid credentials for ping' )
7476 end
7577
7678 it 'should redirect to error page when there is exception' do
@@ -132,17 +134,19 @@ class MyLdapProvider < OmniAuth::Strategies::LDAP; end
132134 it 'should redirect to error page' do
133135 post ( '/auth/ldap/callback' , { :username => 'ping' , :password => 'password' } )
134136
135- last_response . should be_redirect
136- last_response . headers [ 'Location' ] . should =~ %r{invalid_credentials}
137+ expect ( last_response ) . to be_redirect
138+ expect ( last_response . headers [ 'Location' ] ) . to match ( 'invalid_credentials' )
139+ expect ( last_request . env [ 'omniauth.error' ] . message ) . to eq ( 'Invalid credentials for ping' )
137140 end
138141 context 'and filter is set' do
139142 it 'should bind with filter' do
140143 @adaptor . stub ( :filter ) . and_return ( 'uid=%{username}' )
141144 Net ::LDAP ::Filter . should_receive ( :construct ) . with ( 'uid=ping' )
142145 post ( '/auth/ldap/callback' , { :username => 'ping' , :password => 'password' } )
143146
144- last_response . should be_redirect
145- last_response . headers [ 'Location' ] . should =~ %r{invalid_credentials}
147+ expect ( last_response ) . to be_redirect
148+ expect ( last_response . headers [ 'Location' ] ) . to match ( 'invalid_credentials' )
149+ expect ( last_request . env [ 'omniauth.error' ] . message ) . to eq ( 'Invalid credentials for ping' )
146150 end
147151 end
148152
0 commit comments