File: 0050-tests-support-rspec3.patch

package info (click to toggle)
ruby-dataobjects 0.10.16-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 596 kB
  • ctags: 210
  • sloc: ruby: 2,984; makefile: 4
file content (424 lines) | stat: -rw-r--r-- 13,307 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
Description: Make test files support RSpec3
 The test files are tweaked to support RSpec 3 syntax
Author: Balasankar C <balasankarc@autistici.org>
Last-Update: 2015-07-21
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/spec/command_spec.rb
+++ b/spec/command_spec.rb
@@ -12,13 +12,13 @@
 
   %w{connection execute_non_query execute_reader set_types}.each do |meth|
     it "should respond to ##{meth}" do
-      @command.should respond_to(meth.intern)
+      expect(@command).to respond_to(meth.intern)
     end
   end
 
   %w{execute_non_query execute_reader set_types}.each do |meth|
     it "should raise NotImplementedError on ##{meth}" do
-      lambda { @command.send(meth.intern, nil) }.should raise_error(NotImplementedError)
+      expect { @command.send(meth.intern, nil) }.to raise_error(NotImplementedError)
     end
   end
 
--- a/spec/connection_spec.rb
+++ b/spec/connection_spec.rb
@@ -11,10 +11,13 @@
   context 'should define a standard API' do
     let(:uri)   { 'mock://localhost'      }
 
-    it { should respond_to(:dispose)        }
-    it { should respond_to(:create_command) }
+    it { is_expected.to respond_to(:dispose)        }
+    it { is_expected.to respond_to(:create_command) }
 
-    its(:to_s)  { should == 'mock://localhost' }
+    describe '#to_s' do
+      subject { super().to_s }
+      it { is_expected.to eq('mock://localhost') }
+    end
   end
 
   describe 'initialization' do
@@ -22,10 +25,13 @@
     context 'with a connection uri as a Addressable::URI' do
       let(:uri)  { Addressable::URI::parse('mock://localhost/database') }
 
-      it { should be_kind_of(DataObjects::Mock::Connection) }
-      it { should be_kind_of(DataObjects::Pooling)          }
+      it { is_expected.to be_kind_of(DataObjects::Mock::Connection) }
+      it { is_expected.to be_kind_of(DataObjects::Pooling)          }
 
-      its(:to_s) { should == 'mock://localhost/database' }
+      describe '#to_s' do
+        subject { super().to_s }
+        it { is_expected.to eq('mock://localhost/database') }
+      end
     end
 
     [
@@ -35,8 +41,8 @@
     context 'should return the Connection specified by the scheme without pooling' do
       let(:uri)  { jndi_url }
 
-      it { should be_kind_of(DataObjects::Mock2::Connection) }
-      it { should_not be_kind_of(DataObjects::Pooling)       }
+      it { is_expected.to be_kind_of(DataObjects::Mock2::Connection) }
+      it { is_expected.not_to be_kind_of(DataObjects::Pooling)       }
     end
   end
 
@@ -52,7 +58,7 @@
       context "with JDBC URL '#{jdbc_url}'" do
         let(:uri)  { jdbc_url }
 
-        it { should be_kind_of(DataObjects::Mock::Connection) }
+        it { is_expected.to be_kind_of(DataObjects::Mock::Connection) }
       end
     end
 
--- a/spec/pooling_spec.rb
+++ b/spec/pooling_spec.rb
@@ -80,7 +80,7 @@
     ted = Person.new('Ted')
 
     Person.__pools.each do |args, pool|
-      pool.size.should == 1
+      expect(pool.size).to eq(1)
     end
 
     bob.release
@@ -88,31 +88,31 @@
     ted.release
 
     Person.__pools.each do |args, pool|
-      pool.size.should == 1
+      expect(pool.size).to eq(1)
     end
   end
 
   it "should track the initialized pools" do
     bob = Person.new('Bob') # Ensure the pool is "primed"
-    bob.name.should == 'Bob'
-    bob.instance_variable_get(:@__pool).should_not be_nil
-    Person.__pools.size.should == 1
+    expect(bob.name).to eq('Bob')
+    expect(bob.instance_variable_get(:@__pool)).not_to be_nil
+    expect(Person.__pools.size).to eq(1)
     bob.release
-    Person.__pools.size.should == 1
+    expect(Person.__pools.size).to eq(1)
 
-    DataObjects::Pooling::pools.should_not be_empty
+    expect(DataObjects::Pooling::pools).not_to be_empty
 
     sleep(1.2)
 
     # NOTE: This assertion is commented out, as our MockConnection objects are
     #       currently in the pool.
     # DataObjects::Pooling::pools.should be_empty
-    bob.name.should be_nil
+    expect(bob.name).to be_nil
   end
 
   it "should allow you to overwrite Class#new" do
     bob = Overwriter.new('Bob')
-    bob.should be_overwritten
+    expect(bob).to be_overwritten
     bob.release
   end
 
@@ -123,11 +123,11 @@
       bob.release
     end
 
-    lambda do
+    expect do
       bob = Person.new('Bob')
       t1.join
       bob.release
-    end.should_not raise_error(DataObjects::Pooling::InvalidResourceError)
+    end.not_to raise_error
   end
 
   it "should allow you to flush a pool" do
@@ -135,13 +135,13 @@
     Overwriter.new('Bob').release
     bob.release
 
-    bob.name.should == 'Bob'
+    expect(bob.name).to eq('Bob')
 
-    Overwriter.__pools[['Bob']].size.should == 2
+    expect(Overwriter.__pools[['Bob']].size).to eq(2)
     Overwriter.__pools[['Bob']].flush!
-    Overwriter.__pools[['Bob']].size.should == 0
+    expect(Overwriter.__pools[['Bob']].size).to eq(0)
 
-    bob.name.should be_nil
+    expect(bob.name).to be_nil
   end
 
   it "should wake up the scavenger thread when exiting" do
@@ -149,14 +149,14 @@
     bob.release
     DataObjects.exiting = true
     sleep(1)
-    DataObjects::Pooling.scavenger?.should be_false
+    expect(DataObjects::Pooling.scavenger?).to be_falsey
   end
 
   it "should be able to detach an instance from the pool" do
     bob = Person.new('Bob')
-    Person.__pools[['Bob']].size.should == 1
+    expect(Person.__pools[['Bob']].size).to eq(1)
     bob.detach
-    Person.__pools[['Bob']].size.should == 0
+    expect(Person.__pools[['Bob']].size).to eq(0)
   end
 
 end
--- a/spec/reader_spec.rb
+++ b/spec/reader_spec.rb
@@ -10,13 +10,13 @@
 
   context 'should define a standard API' do
 
-    it { should be_a(Enumerable)    }
+    it { is_expected.to be_a(Enumerable)    }
 
-    it { should respond_to(:close)  }
-    it { should respond_to(:next!)  }
-    it { should respond_to(:values) }
-    it { should respond_to(:fields) }
-    it { should respond_to(:each)   }
+    it { is_expected.to respond_to(:close)  }
+    it { is_expected.to respond_to(:next!)  }
+    it { is_expected.to respond_to(:values) }
+    it { is_expected.to respond_to(:fields) }
+    it { is_expected.to respond_to(:each)   }
   end
 
 end
--- a/spec/result_spec.rb
+++ b/spec/result_spec.rb
@@ -11,12 +11,12 @@
   context 'should define a standard API' do
 
     it 'should provide the number of affected rows' do
-      should respond_to(:to_i)
-      subject.to_i.should == 0
+      is_expected.to respond_to(:to_i)
+      expect(subject.to_i).to eq(0)
     end
 
     it 'should provide the id of the inserted row' do
-      should respond_to(:insert_id)
+      is_expected.to respond_to(:insert_id)
     end
 
   end
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,7 +1,6 @@
 require 'rubygems'
 require 'data_objects'
 require 'rspec'
-require 'rspec/its'
 
 module DataObjects::Pooling
   class << self
--- a/spec/transaction_spec.rb
+++ b/spec/transaction_spec.rb
@@ -3,36 +3,36 @@
 describe DataObjects::Transaction do
 
   before :each do
-    @connection = mock("connection")
-    DataObjects::Connection.should_receive(:new).with("mock://mock/mock").once.and_return(@connection)
+    @connection = double("connection")
+    expect(DataObjects::Connection).to receive(:new).with("mock://mock/mock").once.and_return(@connection)
     @transaction = DataObjects::Transaction.new("mock://mock/mock")
   end
 
   it "should have a HOST constant" do
-    DataObjects::Transaction::HOST.should_not == nil?
+    expect(DataObjects::Transaction::HOST).not_to eq(nil?)
   end
 
   describe "#initialize" do
     it "should provide a connection" do
-      @transaction.connection.should == @connection
+      expect(@transaction.connection).to eq(@connection)
     end
     it "should provide an id" do
-      @transaction.id.should_not == nil
+      expect(@transaction.id).not_to eq(nil)
     end
     it "should provide a unique id" do
-      DataObjects::Connection.should_receive(:new).with("mock://mock/mock2").once.and_return(@connection)
-      @transaction.id.should_not == DataObjects::Transaction.new("mock://mock/mock2").id
+      expect(DataObjects::Connection).to receive(:new).with("mock://mock/mock2").once.and_return(@connection)
+      expect(@transaction.id).not_to eq(DataObjects::Transaction.new("mock://mock/mock2").id)
     end
   end
   describe "#close" do
     it "should close its connection" do
-      @connection.should_receive(:close).once
-      lambda { @transaction.close }.should_not raise_error(DataObjects::TransactionError)
+      expect(@connection).to receive(:close).once
+      expect { @transaction.close }.not_to raise_error
     end
   end
   [:prepare, :commit_prepared, :rollback_prepared].each do |meth|
     it "should raise NotImplementedError on #{meth}" do
-      lambda { @transaction.send(meth) }.should raise_error(NotImplementedError)
+      expect { @transaction.send(meth) }.to raise_error(NotImplementedError)
     end
   end
 
--- a/spec/uri_spec.rb
+++ b/spec/uri_spec.rb
@@ -6,46 +6,119 @@
   context 'parsing parts' do
     let(:uri) { 'mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }
 
-    its(:scheme)    { should == 'mock'      }
-    its(:user)      { should == 'username'  }
-    its(:password)  { should == 'password'  }
-    its(:host)      { should == 'localhost' }
-    its(:port)      { should == 12345       }
-    its(:path)      { should == '/path'     }
-    its(:query)     { should == { 'encoding' => 'utf8' } }
-    its(:fragment)  { should == 'fragment'  }
+    describe '#scheme' do
+      subject { super().scheme }
+      it { is_expected.to eq('mock')      }
+    end
+
+    describe '#user' do
+      subject { super().user }
+      it { is_expected.to eq('username')  }
+    end
+
+    describe '#password' do
+      subject { super().password }
+      it { is_expected.to eq('password')  }
+    end
+
+    describe '#host' do
+      subject { super().host }
+      it { is_expected.to eq('localhost') }
+    end
+
+    describe '#port' do
+      subject { super().port }
+      it { is_expected.to eq(12345)       }
+    end
+
+    describe '#path' do
+      subject { super().path }
+      it { is_expected.to eq('/path')     }
+    end
+
+    describe '#query' do
+      subject { super().query }
+      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
+    end
+
+    describe '#fragment' do
+      subject { super().fragment }
+      it { is_expected.to eq('fragment')  }
+    end
 
     it 'should provide a correct string representation' do
-      subject.to_s.should == 'mock://username@localhost:12345/path?encoding=utf8#fragment'
+      expect(subject.to_s).to eq('mock://username@localhost:12345/path?encoding=utf8#fragment')
     end
   end
 
   context 'parsing JDBC URL parts' do
     let(:uri) { 'jdbc:mock://username:password@localhost:12345/path?encoding=utf8#fragment'  }
 
-    its(:scheme)    { should == 'jdbc'      }
-    its(:subscheme) { should == 'mock'      }
-    its(:user)      { should == 'username'  }
-    its(:password)  { should == 'password'  }
-    its(:host)      { should == 'localhost' }
-    its(:port)      { should == 12345       }
-    its(:path)      { should == '/path'     }
-    its(:query)     { should == { 'encoding' => 'utf8' } }
-    its(:fragment)  { should == 'fragment'  }
+    describe '#scheme' do
+      subject { super().scheme }
+      it { is_expected.to eq('jdbc')      }
+    end
+
+    describe '#subscheme' do
+      subject { super().subscheme }
+      it { is_expected.to eq('mock')      }
+    end
+
+    describe '#user' do
+      subject { super().user }
+      it { is_expected.to eq('username')  }
+    end
+
+    describe '#password' do
+      subject { super().password }
+      it { is_expected.to eq('password')  }
+    end
+
+    describe '#host' do
+      subject { super().host }
+      it { is_expected.to eq('localhost') }
+    end
+
+    describe '#port' do
+      subject { super().port }
+      it { is_expected.to eq(12345)       }
+    end
+
+    describe '#path' do
+      subject { super().path }
+      it { is_expected.to eq('/path')     }
+    end
+
+    describe '#query' do
+      subject { super().query }
+      it { is_expected.to eq({ 'encoding' => 'utf8' }) }
+    end
+
+    describe '#fragment' do
+      subject { super().fragment }
+      it { is_expected.to eq('fragment')  }
+    end
 
     it 'should provide a correct string representation' do
-      subject.to_s.should == 'jdbc:mock://username@localhost:12345/path?encoding=utf8#fragment'
+      expect(subject.to_s).to eq('jdbc:mock://username@localhost:12345/path?encoding=utf8#fragment')
     end
   end
 
   context 'parsing parts' do
     let(:uri) { 'java:comp/env/jdbc/TestDataSource'  }
 
-    its(:scheme)    { should == 'java' }
-    its(:path)      { should == 'comp/env/jdbc/TestDataSource'     }
+    describe '#scheme' do
+      subject { super().scheme }
+      it { is_expected.to eq('java') }
+    end
+
+    describe '#path' do
+      subject { super().path }
+      it { is_expected.to eq('comp/env/jdbc/TestDataSource')     }
+    end
 
     it 'should provide a correct string representation' do
-      subject.to_s.should == 'java:comp/env/jdbc/TestDataSource'
+      expect(subject.to_s).to eq('java:comp/env/jdbc/TestDataSource')
     end
   end