File: port-tests-rspec3.patch

package info (click to toggle)
ruby-omniauth-ldap 2.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 176 kB
  • sloc: ruby: 674; makefile: 3
file content (157 lines) | stat: -rw-r--r-- 6,512 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Description: Port tests to new RSpec3 syntax
Author: Balasankar C <balasankarc@autistici.org>
Forwarded: https://github.com/intridea/omniauth-ldap/pull/64
Last-Update: 2016-01-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/spec/omniauth/strategies/ldap_spec.rb
+++ b/spec/omniauth/strategies/ldap_spec.rb
@@ -33,19 +33,19 @@
     before(:each){ get '/auth/ldap' }
 
     it 'should display a form' do
-      last_response.status.should == 200
-      last_response.body.should be_include("<form")
+      expect(last_response.status).to eq(200)
+      expect(last_response.body).to be_include("<form")
     end
 
     it 'should have the callback as the action for the form' do
-      last_response.body.should be_include("action='/auth/ldap/callback'")
+      expect(last_response.body).to be_include("action='/auth/ldap/callback'")
     end
 
     it 'should have a text field for each of the fields' do
-      last_response.body.scan('<input').size.should == 2
+      expect(last_response.body.scan('<input').size).to eq(2)
     end
     it 'should have a label of the form title' do
-      last_response.body.scan('MyLdap Form').size.should > 1
+      expect(last_response.body.scan('MyLdap Form').size).to be > 1
     end
   end
 
@@ -53,12 +53,12 @@
     before(:each) do
       @adaptor = double(OmniAuth::LDAP::Adaptor, {:uid => 'ping'})
       @adaptor.stub(:filter)
-      OmniAuth::LDAP::Adaptor.stub(:new).and_return(@adaptor)
+      allow(OmniAuth::LDAP::Adaptor).to receive(:new).and_return(@adaptor)
     end
 
     context 'failure' do
       before(:each) do
-        @adaptor.stub(:bind_as).and_return(false)
+        allow(@adaptor).to receive(:bind_as).and_return(false)
       end
 
       it 'should fail with missing_credentials' do
@@ -95,8 +95,8 @@
         it 'should redirect to error page' do
           post('/auth/ldap/callback', {})
 
-          last_response.should be_redirect
-          last_response.headers['Location'].should =~ %r{missing_credentials}
+          expect(last_response).to be_redirect
+          expect(last_response.headers['Location']).to match(%r{missing_credentials})
         end
       end
 
@@ -104,8 +104,8 @@
         it 'should redirect to error page' do
           post('/auth/ldap/callback', {:username => ""})
 
-          last_response.should be_redirect
-          last_response.headers['Location'].should =~ %r{missing_credentials}
+          expect(last_response).to be_redirect
+          expect(last_response.headers['Location']).to match(%r{missing_credentials})
         end
       end
 
@@ -114,8 +114,8 @@
           it 'should redirect to error page' do
             post('/auth/ldap/callback', {:username => "ping"})
 
-            last_response.should be_redirect
-            last_response.headers['Location'].should =~ %r{missing_credentials}
+            expect(last_response).to be_redirect
+            expect(last_response.headers['Location']).to match(%r{missing_credentials})
           end
         end
 
@@ -123,8 +123,8 @@
           it 'should redirect to error page' do
             post('/auth/ldap/callback', {:username => "ping", :password => ""})
 
-            last_response.should be_redirect
-            last_response.headers['Location'].should =~ %r{missing_credentials}
+            expect(last_response).to be_redirect
+            expect(last_response.headers['Location']).to match(%r{missing_credentials})
           end
         end
       end
@@ -154,14 +154,14 @@
 
         context "and communication with LDAP server caused an exception" do
           before :each do
-            @adaptor.stub(:bind_as).and_throw(Exception.new('connection_error'))
+            allow(@adaptor).to receive(:bind_as).and_throw(Exception.new('connection_error'))
           end
 
           it 'should redirect to error page' do
             post('/auth/ldap/callback', {:username => "ping", :password => "password"})
 
-            last_response.should be_redirect
-            last_response.headers['Location'].should =~ %r{ldap_error}
+            expect(last_response).to be_redirect
+            expect(last_response.headers['Location']).to match(%r{ldap_error})
           end
         end
       end
@@ -172,7 +172,7 @@
 
       before(:each) do
         @adaptor.stub(:filter)
-        @adaptor.stub(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
+        allow(@adaptor).to receive(:bind_as).and_return(Net::LDAP::Entry.from_single_ldif_string(
 %Q{dn: cn=ping, dc=intridea, dc=com
 mail: ping@intridea.com
 givenname: Ping
@@ -204,24 +204,24 @@
           Net::LDAP::Filter.should_receive(:construct).with('uid=ping')
           post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
 
-          last_response.should_not be_redirect
+        expect(last_response).not_to be_redirect
         end
       end
 
       it 'should map user info to Auth Hash' do
         post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
-        auth_hash.uid.should == 'cn=ping, dc=intridea, dc=com'
-        auth_hash.info.email.should == 'ping@intridea.com'
-        auth_hash.info.first_name.should == 'Ping'
-        auth_hash.info.last_name.should == 'Yu'
-        auth_hash.info.phone.should == '555-555-5555'
-        auth_hash.info.mobile.should == '444-444-4444'
-        auth_hash.info.nickname.should == 'ping'
-        auth_hash.info.title.should == 'dev'
-        auth_hash.info.location.should == 'k street, Washington, DC, U.S.A 20001'
-        auth_hash.info.url.should == 'www.intridea.com'
-        auth_hash.info.image.should == 'http://www.intridea.com/ping.jpg'
-        auth_hash.info.description.should == 'omniauth-ldap'
+        expect(auth_hash.uid).to eq('cn=ping, dc=intridea, dc=com')
+        expect(auth_hash.info.email).to eq('ping@intridea.com')
+        expect(auth_hash.info.first_name).to eq('Ping')
+        expect(auth_hash.info.last_name).to eq('Yu')
+        expect(auth_hash.info.phone).to eq('555-555-5555')
+        expect(auth_hash.info.mobile).to eq('444-444-4444')
+        expect(auth_hash.info.nickname).to eq('ping')
+        expect(auth_hash.info.title).to eq('dev')
+        expect(auth_hash.info.location).to eq('k street, Washington, DC, U.S.A 20001')
+        expect(auth_hash.info.url).to eq('www.intridea.com')
+        expect(auth_hash.info.image).to eq('http://www.intridea.com/ping.jpg')
+        expect(auth_hash.info.description).to eq('omniauth-ldap')
       end
     end