ribs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +54 -24
- data/Rakefile +1 -1
- data/lib/ribs.jar +0 -0
- data/lib/ribs.rb +32 -11
- data/lib/ribs/db.rb +10 -10
- data/lib/ribs/definition.rb +115 -151
- data/lib/ribs/{session.rb → handle.rb} +30 -24
- data/lib/ribs/repository.rb +243 -0
- data/lib/ribs/rib.rb +100 -0
- data/test/artist_spec.rb +22 -20
- data/test/define_accessors_spec.rb +27 -0
- data/test/define_model_spec.rb +41 -0
- data/test/identity_map_spec.rb +63 -0
- data/test/repository_spec.rb +79 -0
- data/test/rib_spec.rb +73 -0
- data/test/simple_select_spec.rb +22 -22
- data/test/test_helper.rb +89 -8
- data/test/track_spec.rb +90 -78
- metadata +10 -4
- data/lib/ribs/meat.rb +0 -33
data/test/test_helper.rb
CHANGED
@@ -20,21 +20,68 @@ Ribs::DB.define do |db|
|
|
20
20
|
db.dialect = 'Derby'
|
21
21
|
db.uri = 'jdbc:derby:test_database;create=true'
|
22
22
|
db.driver = 'org.apache.derby.jdbc.EmbeddedDriver'
|
23
|
+
db.default = true
|
23
24
|
# db.properties['hibernate.show_sql'] = 'true'
|
24
25
|
end
|
25
26
|
|
27
|
+
Ribs::DB.define(:flarg) do |db|
|
28
|
+
db.dialect = 'Derby'
|
29
|
+
db.uri = 'jdbc:derby:test_database_flarg;create=true'
|
30
|
+
db.driver = 'org.apache.derby.jdbc.EmbeddedDriver'
|
31
|
+
end
|
32
|
+
|
33
|
+
Ribs::DB.define(:flurg) do |db|
|
34
|
+
db.dialect = 'Derby'
|
35
|
+
db.uri = 'jdbc:derby:test_database_flurg;create=true'
|
36
|
+
db.driver = 'org.apache.derby.jdbc.EmbeddedDriver'
|
37
|
+
end
|
38
|
+
|
26
39
|
def reset_database!
|
27
|
-
Ribs.
|
28
|
-
|
29
|
-
|
40
|
+
Ribs.with_handle(:flarg) do |h|
|
41
|
+
h.ddl "DROP TABLE FAKEMODEL" rescue nil
|
42
|
+
h.ddl "DROP TABLE FAKEMODEL_FAKESECONDMODEL" rescue nil
|
43
|
+
h.ddl <<SQL
|
44
|
+
CREATE TABLE FAKEMODEL (
|
45
|
+
ID INT NOT NULL
|
46
|
+
)
|
47
|
+
SQL
|
48
|
+
h.ddl <<SQL
|
49
|
+
CREATE TABLE FAKEMODEL_FAKESECONDMODEL (
|
50
|
+
ID INT NOT NULL
|
51
|
+
)
|
52
|
+
SQL
|
53
|
+
end
|
54
|
+
|
55
|
+
Ribs.with_handle(:flurg) do |h|
|
56
|
+
h.ddl "DROP TABLE FAKEMODEL" rescue nil
|
57
|
+
h.ddl "DROP TABLE FAKEMODEL_FAKESECONDMODEL" rescue nil
|
58
|
+
h.ddl <<SQL
|
59
|
+
CREATE TABLE FAKEMODEL (
|
60
|
+
ID INT NOT NULL
|
61
|
+
)
|
62
|
+
SQL
|
63
|
+
h.ddl <<SQL
|
64
|
+
CREATE TABLE FAKEMODEL_FAKESECONDMODEL (
|
65
|
+
ID INT NOT NULL
|
66
|
+
)
|
67
|
+
SQL
|
68
|
+
end
|
69
|
+
|
70
|
+
Ribs.with_handle do |h|
|
71
|
+
h.ddl "DROP TABLE DB_TRACK" rescue nil
|
72
|
+
h.ddl "DROP TABLE ARTIST" rescue nil
|
73
|
+
h.ddl "DROP TABLE person" rescue nil
|
74
|
+
h.ddl "DROP TABLE address" rescue nil
|
75
|
+
h.ddl "DROP TABLE FAKEMODEL" rescue nil
|
76
|
+
h.ddl "DROP TABLE FAKEMODEL_FAKESECONDMODEL" rescue nil
|
30
77
|
|
31
78
|
# GENERATED ALWAYS AS IDENTITY
|
32
79
|
# Add new columns for TIMESTAMP, BINARY, DECIMAL, FLOAT, BOOLEAN
|
33
|
-
|
80
|
+
h.ddl <<SQL
|
34
81
|
CREATE TABLE DB_TRACK (
|
35
82
|
TRACK_ID INT NOT NULL,
|
36
83
|
title VARCHAR(255) NOT NULL,
|
37
|
-
filePath VARCHAR(255),
|
84
|
+
filePath VARCHAR(255) NOT NULL,
|
38
85
|
playTime TIME,
|
39
86
|
added DATE,
|
40
87
|
volume INT NOT NULL,
|
@@ -49,25 +96,57 @@ CREATE TABLE DB_TRACK (
|
|
49
96
|
)
|
50
97
|
SQL
|
51
98
|
|
52
|
-
|
99
|
+
h.ddl <<SQL
|
53
100
|
CREATE TABLE ARTIST (
|
54
101
|
ID INT NOT NULL,
|
55
102
|
name VARCHAR(255) NOT NULL,
|
56
103
|
PRIMARY KEY (ID)
|
57
104
|
)
|
105
|
+
SQL
|
106
|
+
|
107
|
+
h.ddl <<SQL
|
108
|
+
CREATE TABLE person (
|
109
|
+
ID INT NOT NULL,
|
110
|
+
given_name VARCHAR(255),
|
111
|
+
sur_name VARCHAR(255) NOT NULL,
|
112
|
+
age INT NOT NULL,
|
113
|
+
PRIMARY KEY (ID)
|
114
|
+
)
|
115
|
+
SQL
|
116
|
+
|
117
|
+
h.ddl <<SQL
|
118
|
+
CREATE TABLE address (
|
119
|
+
ID INT NOT NULL,
|
120
|
+
street VARCHAR(255),
|
121
|
+
postal VARCHAR(255),
|
122
|
+
zip VARCHAR(255),
|
123
|
+
country VARCHAR(255),
|
124
|
+
PRIMARY KEY (ID)
|
125
|
+
)
|
126
|
+
SQL
|
127
|
+
|
128
|
+
h.ddl <<SQL
|
129
|
+
CREATE TABLE FAKEMODEL (
|
130
|
+
ID INT NOT NULL
|
131
|
+
)
|
132
|
+
SQL
|
133
|
+
h.ddl <<SQL
|
134
|
+
CREATE TABLE FAKEMODEL_FAKESECONDMODEL (
|
135
|
+
ID INT NOT NULL
|
136
|
+
)
|
58
137
|
SQL
|
59
138
|
|
60
139
|
template = <<SQL
|
61
140
|
INSERT INTO DB_TRACK(TRACK_ID, title, filePath, playTime, added, volume, lastPlayed, data, description, fraction, otherFraction, good, price) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
62
141
|
SQL
|
63
142
|
|
64
|
-
|
143
|
+
h.insert(template,
|
65
144
|
[1, "foobar", "c:/abc/cde/foo.mp3", [Time.time_at(14,50,0), :time], [Time.local(1984, 12, 13, 0,0,0), :date], 13,
|
66
145
|
[Time.local(1984, 12, 14, 12,3,11), :timestamp], ["abc", :binary], ["foobar", :text], 3.4, 5.7, true, BigDecimal.new("13134.11")],
|
67
146
|
[2, "flux", "d:/abc/cde/flax.mp3", [Time.time_at(16,23,0), :time], [Time.local(1983, 12, 13, 0,0,0), :date], 13,
|
68
147
|
[Time.local(1982, 5, 3, 13,3,7), :timestamp], ["mumsi", :binary], ["maxi", :text], 3.5, 35435.4522234, false, BigDecimal.new("55454.33")])
|
69
148
|
|
70
|
-
|
149
|
+
h.insert("INSERT INTO ARTIST(ID, name) VALUES(?, ?)",
|
71
150
|
[1, "Public Image Ltd"],
|
72
151
|
[2, "New Model Army"],
|
73
152
|
[3, "David Bowie"])
|
@@ -79,5 +158,7 @@ reset_database!
|
|
79
158
|
at_exit do
|
80
159
|
require 'fileutils'
|
81
160
|
FileUtils.rm_rf('test_database')
|
161
|
+
FileUtils.rm_rf('test_database_flarg')
|
162
|
+
FileUtils.rm_rf('test_database_flurg')
|
82
163
|
FileUtils.rm_rf('derby.log')
|
83
164
|
end
|
data/test/track_spec.rb
CHANGED
@@ -1,28 +1,40 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
3
|
class Track
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rib.
|
18
|
-
|
19
|
-
rib.
|
4
|
+
attr_accessor :track_id
|
5
|
+
attr_accessor :track_title
|
6
|
+
attr_accessor :time
|
7
|
+
attr_accessor :date_added
|
8
|
+
attr_accessor :last_played_at
|
9
|
+
attr_accessor :file_data
|
10
|
+
attr_accessor :desc
|
11
|
+
attr_accessor :some_fraction
|
12
|
+
attr_accessor :is_good
|
13
|
+
attr_accessor :full_price
|
14
|
+
attr_accessor :volume
|
15
|
+
|
16
|
+
Ribs! :table => :DB_TRACK, :identity_map => false do |rib|
|
17
|
+
rib.TRACK_ID.primary_key!
|
18
|
+
|
19
|
+
rib.track_title :column => :title
|
20
|
+
rib.time :column => :playTime
|
21
|
+
rib.date_added :column => :added
|
22
|
+
rib.last_played_at :column => :lastPlayed
|
23
|
+
rib.file_data :column => :data
|
24
|
+
rib.desc :column => :description
|
25
|
+
rib.some_fraction :column => :fraction
|
26
|
+
rib.is_good :column => :good
|
27
|
+
rib.full_price :column => :price
|
28
|
+
|
29
|
+
rib.filePath :avoid, :default => "fluxie"
|
20
30
|
end
|
21
31
|
end
|
22
32
|
|
33
|
+
# R(Track).define_accessors
|
34
|
+
|
23
35
|
describe Track do
|
24
36
|
it "should be able to find things based on mapped primary key" do
|
25
|
-
track = Track.
|
37
|
+
track = R(Track).get(2)
|
26
38
|
track.track_id.should == 2
|
27
39
|
track.track_title.should == "flux"
|
28
40
|
track.time.should == Time.time_at(16,23,0)
|
@@ -31,7 +43,7 @@ describe Track do
|
|
31
43
|
end
|
32
44
|
|
33
45
|
it "should have property that wasn't named" do
|
34
|
-
prop = Track.
|
46
|
+
prop = R(Track).metadata['VOLUME']
|
35
47
|
prop.name.should == 'VOLUME'
|
36
48
|
colarr = prop.column_iterator.to_a
|
37
49
|
colarr.length.should == 1
|
@@ -39,63 +51,63 @@ describe Track do
|
|
39
51
|
end
|
40
52
|
|
41
53
|
it "shouldn't have property that's avoided" do
|
42
|
-
Track.
|
54
|
+
R(Track).metadata['filePath'].should be_nil
|
43
55
|
end
|
44
56
|
|
45
57
|
it "should have correct names for defined properties" do
|
46
|
-
props = Track.
|
58
|
+
props = R(Track).metadata.properties
|
47
59
|
# the primary keys aren't actually part of the properties
|
48
60
|
props.keys.sort.should == ['OTHERFRACTION', 'VOLUME', 'track_title', 'time', 'date_added', 'file_data', 'desc', 'some_fraction', 'is_good', 'full_price', 'last_played_at'].sort
|
49
61
|
props.values.map { |p| p.column_iterator.to_a[0].name }.sort.should ==
|
50
62
|
['VOLUME', 'TITLE', 'PLAYTIME', 'ADDED', 'OTHERFRACTION', 'LASTPLAYED', 'DATA', 'DESCRIPTION', 'FRACTION', 'GOOD', 'PRICE'].sort
|
51
63
|
end
|
52
64
|
|
53
|
-
it "should have correct value and type for OTHERFRACTION property" do
|
54
|
-
res = Track.
|
65
|
+
it "should have correct value and type for OTHERFRACTION property from instance variable" do
|
66
|
+
res = R(Track).all.map { |a| a.instance_variable_get :@otherfraction }.sort
|
55
67
|
res[0].should be_close(5.7, 0.00001)
|
56
68
|
res[1].should be_close(35435.4522234, 0.01)
|
57
69
|
end
|
58
70
|
|
59
71
|
it "should have correct value and type for VOLUME property" do
|
60
|
-
Track.
|
72
|
+
R(Track).all.map { |a| a.volume }.sort.should == [13, 13]
|
61
73
|
end
|
62
74
|
|
63
75
|
it "should have correct value and type for track_title property" do
|
64
|
-
Track.
|
76
|
+
R(Track).all.map { |a| a.track_title }.sort.should == ["flux", "foobar"]
|
65
77
|
end
|
66
78
|
|
67
79
|
it "should have correct value and type for time property" do
|
68
|
-
Track.
|
80
|
+
R(Track).all.map { |a| a.time }.sort.should == [Time.time_at(14,50,0), Time.time_at(16,23,0)]
|
69
81
|
end
|
70
82
|
|
71
83
|
it "should have correct value and type for date_added property" do
|
72
|
-
Track.
|
84
|
+
R(Track).all.map { |a| a.date_added }.sort.should == [Time.local(1983, 12, 13, 0, 0, 0),Time.local(1984, 12, 13, 0, 0, 0)]
|
73
85
|
end
|
74
86
|
|
75
87
|
it "should have correct value and type for file_data property" do
|
76
|
-
Track.
|
88
|
+
R(Track).all.map { |a| a.file_data }.sort.should == ["abc", "mumsi"]
|
77
89
|
end
|
78
90
|
|
79
91
|
it "should have correct value and type for desc property" do
|
80
|
-
Track.
|
92
|
+
R(Track).all.map { |a| a.desc }.sort.should == ["foobar", "maxi"]
|
81
93
|
end
|
82
94
|
|
83
95
|
it "should have correct value and type for some_fraction property" do
|
84
|
-
res = Track.
|
96
|
+
res = R(Track).all.map { |a| a.some_fraction }.sort
|
85
97
|
res[0].should be_close(3.4, 0.00001)
|
86
98
|
res[1].should be_close(3.5, 0.00001)
|
87
99
|
end
|
88
100
|
|
89
101
|
it "should have correct value and type for is_good property" do
|
90
|
-
Track.
|
102
|
+
R(Track).all.map { |a| a.is_good }.sort_by{|v| v ? 0 : 1}.should == [true, false]
|
91
103
|
end
|
92
104
|
|
93
105
|
it "should have correct value and type for full_price property" do
|
94
|
-
Track.
|
106
|
+
R(Track).all.map { |a| a.full_price }.sort.should == [BigDecimal.new("13134.11"), BigDecimal.new("55454.33")]
|
95
107
|
end
|
96
108
|
|
97
109
|
it "should have correct value and type for last_played_at property" do
|
98
|
-
Track.
|
110
|
+
R(Track).all.map { |a| a.last_played_at }.sort.should == [Time.local(1982, 5, 3, 13,3,7), Time.local(1984, 12, 14, 12,3,11)]
|
99
111
|
end
|
100
112
|
|
101
113
|
it "should be possible to create a new instance by setting properties" do
|
@@ -113,11 +125,11 @@ describe Track do
|
|
113
125
|
track.full_price = BigDecimal.new("14.49")
|
114
126
|
track.volume = 5
|
115
127
|
|
116
|
-
Track.
|
128
|
+
R(Track).get(3).should be_nil
|
117
129
|
|
118
|
-
track.save
|
130
|
+
R(track).save
|
119
131
|
|
120
|
-
Track.
|
132
|
+
R(Track).get(3).should_not be_nil
|
121
133
|
ensure
|
122
134
|
reset_database!
|
123
135
|
end
|
@@ -125,7 +137,7 @@ describe Track do
|
|
125
137
|
|
126
138
|
it "should be possible to create a new instance by giving properties to new" do
|
127
139
|
begin
|
128
|
-
track = Track.new(
|
140
|
+
track = R(Track).new(
|
129
141
|
:track_id => 3,
|
130
142
|
:track_title => "Born to raise hell",
|
131
143
|
:time => Time.time_at(0,3,25),
|
@@ -138,11 +150,11 @@ describe Track do
|
|
138
150
|
:full_price => BigDecimal.new("14.49"),
|
139
151
|
:volume => 5)
|
140
152
|
|
141
|
-
Track.
|
153
|
+
R(Track).get(3).should be_nil
|
142
154
|
|
143
|
-
track.save
|
155
|
+
R(track).save
|
144
156
|
|
145
|
-
Track.
|
157
|
+
R(Track).get(3).should_not be_nil
|
146
158
|
ensure
|
147
159
|
reset_database!
|
148
160
|
end
|
@@ -150,8 +162,8 @@ describe Track do
|
|
150
162
|
|
151
163
|
it "should be possible to create a new instance by using create" do
|
152
164
|
begin
|
153
|
-
Track.
|
154
|
-
track = Track.create(
|
165
|
+
R(Track).get(3).should be_nil
|
166
|
+
track = R(Track).create(
|
155
167
|
:track_id => 3,
|
156
168
|
:track_title => "Born to raise hell",
|
157
169
|
:time => Time.time_at(0,3,25),
|
@@ -164,14 +176,14 @@ describe Track do
|
|
164
176
|
:full_price => BigDecimal.new("14.49"),
|
165
177
|
:volume => 5)
|
166
178
|
|
167
|
-
Track.
|
179
|
+
R(Track).get(3).should_not be_nil
|
168
180
|
ensure
|
169
181
|
reset_database!
|
170
182
|
end
|
171
183
|
end
|
172
184
|
|
173
185
|
def create_simple
|
174
|
-
Track.create(
|
186
|
+
R(Track).create(
|
175
187
|
:track_id => 3,
|
176
188
|
:track_title => "Born to raise hell",
|
177
189
|
:time => Time.time_at(0,3,25),
|
@@ -184,7 +196,7 @@ describe Track do
|
|
184
196
|
:full_price => BigDecimal.new("14.49"),
|
185
197
|
:volume => 5)
|
186
198
|
|
187
|
-
Track.
|
199
|
+
R(Track).get(3)
|
188
200
|
end
|
189
201
|
|
190
202
|
it "should have correct value and type for TRACK_ID property on newly created bean" do
|
@@ -277,11 +289,11 @@ describe Track do
|
|
277
289
|
|
278
290
|
it "should be possible to update track_title property on existing bean" do
|
279
291
|
begin
|
280
|
-
v = Track.
|
292
|
+
v = R(Track).get(1)
|
281
293
|
v.track_title = "new value here"
|
282
|
-
v.save
|
294
|
+
R(v).save
|
283
295
|
|
284
|
-
Track.
|
296
|
+
R(Track).get(1).track_title.should == "new value here"
|
285
297
|
ensure
|
286
298
|
reset_database!
|
287
299
|
end
|
@@ -289,11 +301,11 @@ describe Track do
|
|
289
301
|
|
290
302
|
it "should be possible to update time property on existing bean" do
|
291
303
|
begin
|
292
|
-
v = Track.
|
304
|
+
v = R(Track).get(1)
|
293
305
|
v.time = Time.time_at(23,32,33)
|
294
|
-
v.save
|
306
|
+
R(v).save
|
295
307
|
|
296
|
-
Track.
|
308
|
+
R(Track).get(1).time.should == Time.time_at(23,32,33)
|
297
309
|
ensure
|
298
310
|
reset_database!
|
299
311
|
end
|
@@ -301,11 +313,11 @@ describe Track do
|
|
301
313
|
|
302
314
|
it "should be possible to update date_added property on existing bean" do
|
303
315
|
begin
|
304
|
-
v = Track.
|
316
|
+
v = R(Track).get(1)
|
305
317
|
v.date_added = Time.local(2004,10,9,0,0,0)
|
306
|
-
v.save
|
318
|
+
R(v).save
|
307
319
|
|
308
|
-
Track.
|
320
|
+
R(Track).get(1).date_added.should == Time.local(2004,10,9,0,0,0)
|
309
321
|
ensure
|
310
322
|
reset_database!
|
311
323
|
end
|
@@ -313,11 +325,11 @@ describe Track do
|
|
313
325
|
|
314
326
|
it "should be possible to update last_played_at property on existing bean" do
|
315
327
|
begin
|
316
|
-
v = Track.
|
328
|
+
v = R(Track).get(1)
|
317
329
|
v.last_played_at = Time.local(2005,8,8,10,24,12)
|
318
|
-
v.save
|
330
|
+
R(v).save
|
319
331
|
|
320
|
-
Track.
|
332
|
+
R(Track).get(1).last_played_at.should == Time.local(2005,8,8,10,24,12)
|
321
333
|
ensure
|
322
334
|
reset_database!
|
323
335
|
end
|
@@ -325,11 +337,11 @@ describe Track do
|
|
325
337
|
|
326
338
|
it "should be possible to update file_data property on existing bean" do
|
327
339
|
begin
|
328
|
-
v = Track.
|
340
|
+
v = R(Track).get(1)
|
329
341
|
v.file_data = "Some data"
|
330
|
-
v.save
|
342
|
+
R(v).save
|
331
343
|
|
332
|
-
Track.
|
344
|
+
R(Track).get(1).file_data.should == "Some data"
|
333
345
|
ensure
|
334
346
|
reset_database!
|
335
347
|
end
|
@@ -337,11 +349,11 @@ describe Track do
|
|
337
349
|
|
338
350
|
it "should be possible to update desc property on existing bean" do
|
339
351
|
begin
|
340
|
-
v = Track.
|
352
|
+
v = R(Track).get(1)
|
341
353
|
v.desc = "Some description"
|
342
|
-
v.save
|
354
|
+
R(v).save
|
343
355
|
|
344
|
-
Track.
|
356
|
+
R(Track).get(1).desc.should == "Some description"
|
345
357
|
ensure
|
346
358
|
reset_database!
|
347
359
|
end
|
@@ -349,11 +361,11 @@ describe Track do
|
|
349
361
|
|
350
362
|
it "should be possible to update some_fraction property on existing bean" do
|
351
363
|
begin
|
352
|
-
v = Track.
|
364
|
+
v = R(Track).get(1)
|
353
365
|
v.some_fraction = 3.1416 #Anal test
|
354
|
-
v.save
|
366
|
+
R(v).save
|
355
367
|
|
356
|
-
Track.
|
368
|
+
R(Track).get(1).some_fraction.should be_close(3.1416, 0.00001)
|
357
369
|
ensure
|
358
370
|
reset_database!
|
359
371
|
end
|
@@ -361,11 +373,11 @@ describe Track do
|
|
361
373
|
|
362
374
|
it "should be possible to update is_good property on existing bean" do
|
363
375
|
begin
|
364
|
-
v = Track.
|
376
|
+
v = R(Track).get(1)
|
365
377
|
v.is_good = false
|
366
|
-
v.save
|
378
|
+
R(v).save
|
367
379
|
|
368
|
-
Track.
|
380
|
+
R(Track).get(1).is_good.should be_false
|
369
381
|
ensure
|
370
382
|
reset_database!
|
371
383
|
end
|
@@ -373,11 +385,11 @@ describe Track do
|
|
373
385
|
|
374
386
|
it "should be possible to update full_price property on existing bean" do
|
375
387
|
begin
|
376
|
-
v = Track.
|
388
|
+
v = R(Track).get(1)
|
377
389
|
v.full_price = BigDecimal.new("142.12")
|
378
|
-
v.save
|
390
|
+
R(v).save
|
379
391
|
|
380
|
-
Track.
|
392
|
+
R(Track).get(1).full_price.should == BigDecimal.new("142.12")
|
381
393
|
ensure
|
382
394
|
reset_database!
|
383
395
|
end
|
@@ -385,11 +397,11 @@ describe Track do
|
|
385
397
|
|
386
398
|
it "should be possible to update volume property on existing bean" do
|
387
399
|
begin
|
388
|
-
v = Track.
|
400
|
+
v = R(Track).get(1)
|
389
401
|
v.volume = 42
|
390
|
-
v.save
|
402
|
+
R(v).save
|
391
403
|
|
392
|
-
Track.
|
404
|
+
R(Track).get(1).volume.should == 42
|
393
405
|
ensure
|
394
406
|
reset_database!
|
395
407
|
end
|
@@ -397,8 +409,8 @@ describe Track do
|
|
397
409
|
|
398
410
|
it "should be possible to delete existing bean" do
|
399
411
|
begin
|
400
|
-
Track.
|
401
|
-
Track.
|
412
|
+
R(R(Track).get(1)).destroy!
|
413
|
+
R(Track).get(1).should be_nil
|
402
414
|
ensure
|
403
415
|
reset_database!
|
404
416
|
end
|
@@ -406,8 +418,8 @@ describe Track do
|
|
406
418
|
|
407
419
|
it "should be possible to delete existing bean by id" do
|
408
420
|
begin
|
409
|
-
Track.destroy(2)
|
410
|
-
Track.
|
421
|
+
R(Track).destroy(2)
|
422
|
+
R(Track).get(2).should be_nil
|
411
423
|
ensure
|
412
424
|
reset_database!
|
413
425
|
end
|