sequel_bitemporal 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,32 +11,32 @@ describe "Sequel::Plugins::Bitemporal", :skip_jdbc_sqlite do
11
11
  end
12
12
  subject{ @master_class.new.update_attributes name: {test: 1}, price: 18 }
13
13
  it "serializes as expected" do
14
- subject.name.should == {"test" => 1}
14
+ expect(subject.name).to eq({"test" => 1})
15
15
  end
16
16
  it "doesn't create a new version when value hasn't changed" do
17
17
  name = subject.name.dup
18
18
  name["test"] = 1
19
19
  subject.attributes = {name: name}
20
- lambda{ subject.save }.should_not change(@version_class, :count)
20
+ expect{ subject.save }.not_to change(@version_class, :count)
21
21
  end
22
22
  it "doesn't create a new version when value is the same" do
23
23
  subject.attributes = {name: {"test" => 1}}
24
- lambda{ subject.save }.should_not change(@version_class, :count)
24
+ expect{ subject.save }.not_to change(@version_class, :count)
25
25
  end
26
26
  it "does create a new version when value has changed" do
27
27
  name = subject.name.dup
28
28
  name["test"] = 0
29
29
  subject.attributes = {name: name}
30
- lambda{ subject.save }.should change(@version_class, :count).by 1
30
+ expect{ subject.save }.to change(@version_class, :count).by 1
31
31
  end
32
32
  it "does create a new version when value is not the same" do
33
33
  subject.attributes = {name: {"test" => 0}}
34
- lambda{ subject.save }.should change(@version_class, :count).by 1
34
+ expect{ subject.save }.to change(@version_class, :count).by 1
35
35
  end
36
36
  it "does allow to restore" do
37
37
  subject.current_version.destroy
38
38
  subject.reload
39
- lambda{ subject.restore }.should change(@version_class, :count).by 1
40
- subject.name.should == {"test" => 1}
39
+ expect{ subject.restore }.to change(@version_class, :count).by 1
40
+ expect(subject.name).to eq({"test" => 1})
41
41
  end
42
42
  end
@@ -12,34 +12,34 @@ describe "Sequel::Plugins::Bitemporal" do
12
12
  Timecop.return
13
13
  end
14
14
  it "checks version class is given" do
15
- lambda{
15
+ expect{
16
16
  @version_class.plugin :bitemporal
17
- }.should raise_error Sequel::Error, "please specify version class to use for bitemporal plugin"
17
+ }.to raise_error Sequel::Error, "please specify version class to use for bitemporal plugin"
18
18
  end
19
19
  it "checks required columns are present" do
20
- lambda{
20
+ expect{
21
21
  @version_class.plugin :bitemporal, :version_class => @master_class
22
- }.should raise_error Sequel::Error, "bitemporal plugin requires the following missing columns on version class: master_id, valid_from, valid_to, created_at, expired_at"
22
+ }.to raise_error Sequel::Error, "bitemporal plugin requires the following missing columns on version class: master_id, valid_from, valid_to, created_at, expired_at"
23
23
  end
24
24
  it "propagates errors from version to master" do
25
25
  master = @master_class.new
26
- master.should be_valid
26
+ expect(master).to be_valid
27
27
  master.attributes = {name: "Single Standard"}
28
- master.should_not be_valid
29
- master.errors.should == {price: ["is required"]}
28
+ expect(master).not_to be_valid
29
+ expect(master.errors).to eq({price: ["is required"]})
30
30
  end
31
31
  it "#update_attributes returns false instead of raising errors" do
32
32
  master = @master_class.new
33
- master.update_attributes(name: "Single Standard").should be_false
34
- master.should be_new
35
- master.errors.should == {price: ["is required"]}
36
- master.update_attributes(price: 98).should be_true
33
+ expect(master.update_attributes(name: "Single Standard")).to be_falsey
34
+ expect(master).to be_new
35
+ expect(master.errors).to eq({price: ["is required"]})
36
+ expect(master.update_attributes(price: 98)).to be_truthy
37
37
  end
38
38
  it "allows creating a master and its first version in one step" do
39
39
  master = @master_class.new
40
- master.update_attributes(name: "Single Standard", price: 98).should be_true
41
- master.should_not be_new
42
- master.should have_versions %Q{
40
+ expect(master.update_attributes(name: "Single Standard", price: 98)).to be_truthy
41
+ expect(master).not_to be_new
42
+ expect(master).to have_versions %Q{
43
43
  | name | price | created_at | expired_at | valid_from | valid_to | current |
44
44
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | MAX TIME | true |
45
45
  }
@@ -47,7 +47,7 @@ describe "Sequel::Plugins::Bitemporal" do
47
47
  it "allows creating a new version in the past" do
48
48
  master = @master_class.new
49
49
  master.update_attributes name: "Single Standard", price: 98, valid_from: Time.now-hour
50
- master.should have_versions %Q{
50
+ expect(master).to have_versions %Q{
51
51
  | name | price | created_at | expired_at | valid_from | valid_to | current |
52
52
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 09:00:00 +0000 | MAX TIME | true |
53
53
  }
@@ -55,7 +55,7 @@ describe "Sequel::Plugins::Bitemporal" do
55
55
  it "allows creating a new version in the future" do
56
56
  master = @master_class.new
57
57
  master.update_attributes name: "Single Standard", price: 98, valid_from: Time.now+hour
58
- master.should have_versions %Q{
58
+ expect(master).to have_versions %Q{
59
59
  | name | price | created_at | expired_at | valid_from | valid_to | current |
60
60
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 11:00:00 +0000 | MAX TIME | |
61
61
  }
@@ -64,7 +64,7 @@ describe "Sequel::Plugins::Bitemporal" do
64
64
  master = @master_class.new
65
65
  master.update_attributes name: "Single Standard", price: 98
66
66
  master.update_attributes name: "Single Standard", price: 94
67
- master.should have_versions %Q{
67
+ expect(master).to have_versions %Q{
68
68
  | name | price | created_at | expired_at | valid_from | valid_to | current |
69
69
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
70
70
  | Single Standard | 94 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | MAX TIME | true |
@@ -75,7 +75,7 @@ describe "Sequel::Plugins::Bitemporal" do
75
75
  master.update_attributes name: "Single Standard", price: 98
76
76
  master.update_attributes price: 94
77
77
  master.update_attributes name: "King Size"
78
- master.should have_versions %Q{
78
+ expect(master).to have_versions %Q{
79
79
  | name | price | created_at | expired_at | valid_from | valid_to | current |
80
80
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
81
81
  | Single Standard | 94 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
@@ -87,7 +87,7 @@ describe "Sequel::Plugins::Bitemporal" do
87
87
  master.update_attributes name: "Single Standard", price: 98
88
88
  Timecop.freeze Time.now+hour
89
89
  master.update_attributes price: 94
90
- master.should have_versions %Q{
90
+ expect(master).to have_versions %Q{
91
91
  | name | price | created_at | expired_at | valid_from | valid_to | current |
92
92
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
93
93
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
@@ -98,9 +98,9 @@ describe "Sequel::Plugins::Bitemporal" do
98
98
  master = @master_class.new
99
99
  master.update_attributes name: "Single Standard", price: 98, valid_to: Time.now+hour
100
100
  Timecop.freeze Time.now+hour
101
- master.update_attributes(price: 94).should be_false
101
+ expect(master.update_attributes(price: 94)).to be_falsey
102
102
  master.update_attributes name: "Single Standard", price: 94
103
- master.should have_versions %Q{
103
+ expect(master).to have_versions %Q{
104
104
  | name | price | created_at | expired_at | valid_from | valid_to | current |
105
105
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
106
106
  | Single Standard | 94 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 11:00:00 +0000 | MAX TIME | true |
@@ -111,7 +111,7 @@ describe "Sequel::Plugins::Bitemporal" do
111
111
  master.update_attributes name: "Single Standard", price: 98
112
112
  Timecop.freeze Time.now+hour
113
113
  master.update_attributes valid_to: Time.now+10*hour
114
- master.should have_versions %Q{
114
+ expect(master).to have_versions %Q{
115
115
  | name | price | created_at | expired_at | valid_from | valid_to | current |
116
116
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
117
117
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
@@ -126,12 +126,12 @@ describe "Sequel::Plugins::Bitemporal" do
126
126
  master = @master_class.new
127
127
  master.update_attributes name: "Single Standard", price: 98, valid_to: Time.now+2*hour
128
128
  Timecop.freeze Time.now+hour
129
- master.should have_versions %Q{
129
+ expect(master).to have_versions %Q{
130
130
  | name | price | created_at | expired_at | valid_from | valid_to | current |
131
131
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | true |
132
132
  }
133
133
  master.update_attributes valid_to: nil
134
- master.should have_versions %Q{
134
+ expect(master).to have_versions %Q{
135
135
  | name | price | created_at | expired_at | valid_from | valid_to | current |
136
136
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
137
137
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
@@ -147,7 +147,7 @@ describe "Sequel::Plugins::Bitemporal" do
147
147
  master.update_attributes name: "Single Standard", price: 98
148
148
  master.update_attributes price: 98
149
149
  master.update_attributes name: "Single Standard", price: 98
150
- master.should have_versions %Q{
150
+ expect(master).to have_versions %Q{
151
151
  | name | price | created_at | expired_at | valid_from | valid_to | current |
152
152
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000| MAX TIME | true |
153
153
  }
@@ -158,7 +158,7 @@ describe "Sequel::Plugins::Bitemporal" do
158
158
  Timecop.freeze Time.now+hour
159
159
  master.update_attributes price: 98, valid_from: Time.now-2*hour
160
160
  master.update_attributes price: 98, valid_from: Time.now+1*hour
161
- master.should have_versions %Q{
161
+ expect(master).to have_versions %Q{
162
162
  | name | price | created_at | expired_at | valid_from | valid_to | current |
163
163
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | MAX TIME | true |
164
164
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 09:00:00 +0000 | 2009-11-28 10:00:00 +0000 | |
@@ -175,7 +175,7 @@ describe "Sequel::Plugins::Bitemporal" do
175
175
  master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
176
176
  Timecop.freeze Time.now+hour
177
177
  master.update_attributes name: "King Size", valid_to: nil
178
- master.should have_versions %Q{
178
+ expect(master).to have_versions %Q{
179
179
  | name | price | created_at | expired_at | valid_from | valid_to | current |
180
180
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
181
181
  | Single Standard | 94 | 2009-11-28 10:00:00 +0000 | | 2009-11-28 12:00:00 +0000 | 2009-11-28 14:00:00 +0000 | |
@@ -191,7 +191,7 @@ describe "Sequel::Plugins::Bitemporal" do
191
191
  master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
192
192
  Timecop.freeze Time.now+hour
193
193
  master.update_attributes name: "King Size", valid_to: Time.now+4*hour
194
- master.should have_versions %Q{
194
+ expect(master).to have_versions %Q{
195
195
  | name | price | created_at | expired_at | valid_from | valid_to | current |
196
196
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
197
197
  | Single Standard | 94 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 12:00:00 +0000 | 2009-11-28 14:00:00 +0000 | |
@@ -208,7 +208,7 @@ describe "Sequel::Plugins::Bitemporal" do
208
208
  master.update_attributes name: "Single Standard", price: 95, valid_from: Time.now+4*hour, valid_to: Time.now+6*hour
209
209
  Timecop.freeze Time.now+hour
210
210
  master.update_attributes name: "King Size", valid_to: Time.utc(9999)
211
- master.should have_versions %Q{
211
+ expect(master).to have_versions %Q{
212
212
  | name | price | created_at | expired_at | valid_from | valid_to | current |
213
213
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
214
214
  | Single Standard | 94 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 12:00:00 +0000 | 2009-11-28 14:00:00 +0000 | |
@@ -222,8 +222,8 @@ describe "Sequel::Plugins::Bitemporal" do
222
222
  master.update_attributes name: "Single Standard", price: 98
223
223
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
224
224
  Timecop.freeze Time.now+hour
225
- master.current_version.destroy.should be_true
226
- master.should have_versions %Q{
225
+ expect(master.current_version.destroy).to be_truthy
226
+ expect(master).to have_versions %Q{
227
227
  | name | price | created_at | expired_at | valid_from | valid_to | current |
228
228
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
229
229
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
@@ -236,8 +236,8 @@ describe "Sequel::Plugins::Bitemporal" do
236
236
  master.update_attributes name: "Single Standard", price: 98
237
237
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
238
238
  Timecop.freeze Time.now+hour
239
- master.versions.last.destroy.should be_true
240
- master.should have_versions %Q{
239
+ expect(master.versions.last.destroy).to be_truthy
240
+ expect(master).to have_versions %Q{
241
241
  | name | price | created_at | expired_at | valid_from | valid_to | current |
242
242
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
243
243
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
@@ -250,8 +250,8 @@ describe "Sequel::Plugins::Bitemporal" do
250
250
  master.update_attributes name: "Single Standard", price: 98
251
251
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
252
252
  Timecop.freeze Time.now+hour
253
- master.destroy.should be_true
254
- master.should have_versions %Q{
253
+ expect(master.destroy).to be_truthy
254
+ expect(master).to have_versions %Q{
255
255
  | name | price | created_at | expired_at | valid_from | valid_to | current |
256
256
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
257
257
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | 2009-11-28 12:00:00 +0000 | |
@@ -265,7 +265,7 @@ describe "Sequel::Plugins::Bitemporal" do
265
265
  master2 = @master_class.find id: master.id
266
266
  master.update_attributes name: "Single Standard", price: 94
267
267
  master2.update_attributes name: "Single Standard", price: 95
268
- master.should have_versions %Q{
268
+ expect(master).to have_versions %Q{
269
269
  | name | price | created_at | expired_at | valid_from | valid_to | current |
270
270
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
271
271
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
@@ -280,7 +280,7 @@ describe "Sequel::Plugins::Bitemporal" do
280
280
  master2 = @master_class.find id: master.id
281
281
  master.update_attributes price: 94
282
282
  master2.update_attributes name: "King Size"
283
- master.should have_versions %Q{
283
+ expect(master).to have_versions %Q{
284
284
  | name | price | created_at | expired_at | valid_from | valid_to | current |
285
285
  | Single Standard | 98 | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | 2009-11-28 10:00:00 +0000 | MAX TIME | |
286
286
  | Single Standard | 98 | 2009-11-28 11:00:00 +0000 | | 2009-11-28 10:00:00 +0000 | 2009-11-28 11:00:00 +0000 | |
@@ -292,10 +292,10 @@ describe "Sequel::Plugins::Bitemporal" do
292
292
  master = @master_class.new
293
293
  master.update_attributes name: "Single Standard", price: 98
294
294
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
295
- @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be
295
+ expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be
296
296
  Timecop.freeze Time.now+hour
297
297
  master.destroy
298
- @master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first.should be_nil
298
+ expect(@master_class.eager_graph(:current_version).where("rooms_current_version.id IS NOT NULL").first).to be_nil
299
299
  end
300
300
  it "allows loading masters with a current version" do
301
301
  master_destroyed = @master_class.new
@@ -305,52 +305,52 @@ describe "Sequel::Plugins::Bitemporal" do
305
305
  master_with_current.update_attributes name: "Single Standard", price: 94
306
306
  master_with_future = @master_class.new
307
307
  master_with_future.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
308
- @master_class.with_current_version.all.should have(1).item
308
+ expect(@master_class.with_current_version.all.size).to eq(1)
309
309
  end
310
310
  it "gets pending or current version attributes" do
311
311
  master = @master_class.new
312
- master.attributes.should == {}
313
- master.pending_version.should be_nil
314
- master.current_version.should be_nil
315
- master.pending_or_current_version.name.should be_nil
316
- master.name.should be_nil
312
+ expect(master.attributes).to eq({})
313
+ expect(master.pending_version).to be_nil
314
+ expect(master.current_version).to be_nil
315
+ expect(master.pending_or_current_version.name).to be_nil
316
+ expect(master.name).to be_nil
317
317
 
318
318
  master.update_attributes name: "Single Standard", price: 98
319
- master.attributes[:name].should == "Single Standard"
320
- master.pending_version.should be_nil
321
- master.pending_or_current_version.name.should == "Single Standard"
322
- master.name.should == "Single Standard"
319
+ expect(master.attributes[:name]).to eq("Single Standard")
320
+ expect(master.pending_version).to be_nil
321
+ expect(master.pending_or_current_version.name).to eq("Single Standard")
322
+ expect(master.name).to eq("Single Standard")
323
323
 
324
324
  master.attributes = {name: "King Size"}
325
- master.attributes[:name].should == "King Size"
326
- master.pending_version.should be
327
- master.pending_or_current_version.name.should == "King Size"
328
- master.name.should == "King Size"
325
+ expect(master.attributes[:name]).to eq("King Size")
326
+ expect(master.pending_version).to be
327
+ expect(master.pending_or_current_version.name).to eq("King Size")
328
+ expect(master.name).to eq("King Size")
329
329
  end
330
330
  it "allows to go back in time" do
331
331
  master = @master_class.new
332
332
  master.update_attributes name: "Single Standard", price: 98
333
333
  Timecop.freeze Time.now+1*hour
334
334
  master.update_attributes price: 94
335
- master.current_version.price.should == 94
335
+ expect(master.current_version.price).to eq(94)
336
336
  Sequel::Plugins::Bitemporal.as_we_knew_it(Time.now-1*hour) do
337
- master.current_version(true).price.should == 98
337
+ expect(master.current_version(true).price).to eq(98)
338
338
  end
339
339
  end
340
340
  it "correctly reset time if failure when going back in time" do
341
341
  before = Sequel::Plugins::Bitemporal.now
342
- lambda do
342
+ expect do
343
343
  Sequel::Plugins::Bitemporal.at(Time.now+1*hour) do
344
344
  raise StandardError, "error during back in time"
345
345
  end
346
- end.should raise_error StandardError
347
- Sequel::Plugins::Bitemporal.now.should == before
348
- lambda do
346
+ end.to raise_error StandardError
347
+ expect(Sequel::Plugins::Bitemporal.now).to eq(before)
348
+ expect do
349
349
  Sequel::Plugins::Bitemporal.as_we_knew_it(Time.now-1*hour) do
350
350
  raise StandardError, "error during back in time"
351
351
  end
352
- end.should raise_error StandardError
353
- Sequel::Plugins::Bitemporal.now.should == before
352
+ end.to raise_error StandardError
353
+ expect(Sequel::Plugins::Bitemporal.now).to eq(before)
354
354
  end
355
355
  it "allows eager loading with conditions on current or future versions" do
356
356
  master = @master_class.new
@@ -359,16 +359,16 @@ describe "Sequel::Plugins::Bitemporal" do
359
359
  master.update_attributes name: "Single Standard", price: 99
360
360
  master.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
361
361
  res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 99}).all.first
362
- res.should be
363
- res.current_or_future_versions.should have(1).item
364
- res.current_or_future_versions.first.price.should == 99
362
+ expect(res).to be
363
+ expect(res.current_or_future_versions.size).to eq(1)
364
+ expect(res.current_or_future_versions.first.price).to eq(99)
365
365
  res = @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil) & {price: 94}).all.first
366
- res.should be
367
- res.current_or_future_versions.should have(1).item
368
- res.current_or_future_versions.first.price.should == 94
366
+ expect(res).to be
367
+ expect(res.current_or_future_versions.size).to eq(1)
368
+ expect(res.current_or_future_versions.first.price).to eq(94)
369
369
  Timecop.freeze Time.now+1*hour
370
370
  master.destroy
371
- @master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all.should be_empty
371
+ expect(@master_class.eager_graph(:current_or_future_versions).where(Sequel.negate(current_or_future_versions__id: nil)).all).to be_empty
372
372
  end
373
373
  it "allows loading masters with current or future versions" do
374
374
  master_destroyed = @master_class.new
@@ -378,7 +378,7 @@ describe "Sequel::Plugins::Bitemporal" do
378
378
  master_with_current.update_attributes name: "Single Standard", price: 94
379
379
  master_with_future = @master_class.new
380
380
  master_with_future.update_attributes name: "Single Standard", price: 94, valid_from: Time.now+2*hour
381
- @master_class.with_current_or_future_versions.all.should have(2).item
381
+ expect(@master_class.with_current_or_future_versions.all.size).to eq(2)
382
382
  end
383
383
  end
384
384
  describe "Sequel::Plugins::Bitemporal", "with audit" do
@@ -395,8 +395,8 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
395
395
  let(:author){ double :author, audit_kind: "user" }
396
396
  it "generates a new audit on creation" do
397
397
  master = @master_class.new
398
- master.should_receive(:updated_by).and_return author
399
- @audit_class.should_receive(:audit).with(
398
+ expect(master).to receive(:updated_by).and_return author
399
+ expect(@audit_class).to receive(:audit).with(
400
400
  master,
401
401
  {},
402
402
  hash_including({name: "Single Standard", price: 98}),
@@ -407,10 +407,10 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
407
407
  end
408
408
  it "generates a new audit on full update" do
409
409
  master = @master_class.new
410
- master.should_receive(:updated_by).twice.and_return author
411
- @audit_class.stub(:audit)
410
+ expect(master).to receive(:updated_by).twice.and_return author
411
+ allow(@audit_class).to receive(:audit)
412
412
  master.update_attributes name: "Single Standard", price: 98
413
- @audit_class.should_receive(:audit).with(
413
+ expect(@audit_class).to receive(:audit).with(
414
414
  master,
415
415
  hash_including({name: "Single Standard", price: 98}),
416
416
  hash_including({name: "King size", price: 98}),
@@ -421,10 +421,10 @@ describe "Sequel::Plugins::Bitemporal", "with audit" do
421
421
  end
422
422
  it "generates a new audit on partial update" do
423
423
  master = @master_class.new
424
- master.should_receive(:updated_by).twice.and_return author
425
- @audit_class.stub(:audit)
424
+ expect(master).to receive(:updated_by).twice.and_return author
425
+ allow(@audit_class).to receive(:audit)
426
426
  master.update_attributes name: "Single Standard", price: 98
427
- @audit_class.should_receive(:audit).with(
427
+ expect(@audit_class).to receive(:audit).with(
428
428
  master,
429
429
  hash_including({name: "Single Standard", price: 98}),
430
430
  hash_including({name: "King size", price: 98}),
@@ -449,8 +449,8 @@ describe "Sequel::Plugins::Bitemporal", "with audit, specifying how to get the a
449
449
  let(:author){ double :author, audit_kind: "user" }
450
450
  it "generates a new audit on creation" do
451
451
  master = @master_class.new
452
- master.should_receive(:author).and_return author
453
- @audit_class.should_receive(:audit).with(
452
+ expect(master).to receive(:author).and_return author
453
+ expect(@audit_class).to receive(:audit).with(
454
454
  master,
455
455
  {},
456
456
  hash_including({name: "Single Standard", price: 98}),
@@ -461,10 +461,10 @@ describe "Sequel::Plugins::Bitemporal", "with audit, specifying how to get the a
461
461
  end
462
462
  it "generates a new audit on update" do
463
463
  master = @master_class.new
464
- master.should_receive(:author).twice.and_return author
465
- @audit_class.stub(:audit)
464
+ expect(master).to receive(:author).twice.and_return author
465
+ allow(@audit_class).to receive(:audit)
466
466
  master.update_attributes name: "Single Standard", price: 98
467
- @audit_class.should_receive(:audit).with(
467
+ expect(@audit_class).to receive(:audit).with(
468
468
  master,
469
469
  hash_including({name: "Single Standard", price: 98}),
470
470
  hash_including({name: "King size", price: 98}),