remodel 0.1.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_entity.rb CHANGED
@@ -13,35 +13,25 @@ class TestEntity < Test::Unit::TestCase
13
13
 
14
14
  context "new" do
15
15
  should "set properties" do
16
- foo = Foo.new :x => 1, :y => 2
17
- assert 1, foo.x
18
- assert 2, foo.y
16
+ foo = Foo.new('cx', :x => 1, :y => 2)
17
+ assert_equal 1, foo.x
18
+ assert_equal 2, foo.y
19
19
  end
20
20
 
21
21
  should "ignore undefined properties" do
22
- foo = Foo.new :z => 3
22
+ foo = Foo.new('cx', :z => 3)
23
23
  assert foo.instance_eval { !@attributes.key? :z }
24
24
  end
25
25
 
26
26
  should "not set the key" do
27
- foo = Foo.new :x => 23
27
+ foo = Foo.new('cx', :x => 23)
28
28
  assert_equal nil, foo.key
29
29
  end
30
30
 
31
31
  should "not set the id" do
32
- foo = Foo.new :x => 23
32
+ foo = Foo.new('cx', :x => 23)
33
33
  assert_equal nil, foo.id
34
34
  end
35
-
36
- should "use default values for missing properties" do
37
- bar = Bar.new
38
- assert_equal 123, bar.d
39
- end
40
-
41
- should "not use default values for given properties" do
42
- bar = Bar.new :d => 'cool'
43
- assert_equal 'cool', bar.d
44
- end
45
35
  end
46
36
 
47
37
  context "create" do
@@ -50,47 +40,37 @@ class TestEntity < Test::Unit::TestCase
50
40
  end
51
41
 
52
42
  should "work without attributes" do
53
- foo = Foo.create
43
+ foo = Foo.create('cx')
54
44
  assert foo.is_a?(Foo)
55
45
  end
56
46
 
57
47
  should "give the entity a key based on the class name" do
58
- assert_equal 'f:1', Foo.create.key
59
- assert_equal 'b:1', Bar.create.key
60
- assert_equal 'b:2', Bar.create.key
48
+ assert_equal 'f1', Foo.create('cx').key
49
+ assert_equal 'b1', Bar.create('cx').key
50
+ assert_equal 'b2', Bar.create('cx').key
61
51
  end
62
52
 
63
53
  should "give the entity an id which is unique per entity class" do
64
- assert_equal 1, Foo.create.id
65
- assert_equal 1, Bar.create.id
66
- assert_equal 2, Bar.create.id
54
+ assert_equal 1, Foo.create('cx').id
55
+ assert_equal 1, Bar.create('cx').id
56
+ assert_equal 2, Bar.create('cx').id
67
57
  end
68
58
 
69
59
  should "store the entity under its key" do
70
- foo = Foo.create :x => 'hello', :y => false
71
- assert redis.exists(foo.key)
60
+ foo = Foo.create('cx', :x => 'hello', :y => false)
61
+ assert redis.hexists('cx', foo.key)
72
62
  end
73
63
 
74
64
  should "store all properties" do
75
- foo = Foo.create :x => 'hello', :y => false
65
+ foo = Foo.create('cx', :x => 'hello', :y => false)
76
66
  foo.reload
77
67
  assert_equal 'hello', foo.x
78
68
  assert_equal false, foo.y
79
69
  end
80
70
 
81
71
  should "not store the key as a property" do
82
- foo = Foo.create :x => 'hello', :y => false
83
- assert !(/f:1/ =~ redis.get(foo.key))
84
- end
85
-
86
- should "use default values for missing properties" do
87
- bar = Bar.create
88
- assert_equal 123, bar.d
89
- end
90
-
91
- should "not use default values for given properties" do
92
- bar = Bar.create :d => 'cool'
93
- assert_equal 'cool', bar.d
72
+ foo = Foo.create('cx', :x => 'hello', :y => false)
73
+ assert !(/f:1/ =~ redis.hget('cx', foo.key))
94
74
  end
95
75
  end
96
76
 
@@ -100,18 +80,18 @@ class TestEntity < Test::Unit::TestCase
100
80
  end
101
81
 
102
82
  should "give the entity a key, if necessary" do
103
- foo = Foo.new.save
83
+ foo = Foo.new('cx').save
104
84
  assert foo.key
105
85
  end
106
86
 
107
87
  should "store the entity under its key" do
108
- foo = Foo.new :x => 'hello', :y => false
88
+ foo = Foo.new('cx', :x => 'hello', :y => false)
109
89
  foo.save
110
- assert redis.exists(foo.key)
90
+ assert redis.hexists(foo.context, foo.key)
111
91
  end
112
92
 
113
93
  should "store all properties" do
114
- foo = Foo.new :x => 'hello', :y => false
94
+ foo = Foo.new('cx', :x => 'hello', :y => false)
115
95
  foo.save
116
96
  foo.reload
117
97
  assert_equal 'hello', foo.x
@@ -121,11 +101,11 @@ class TestEntity < Test::Unit::TestCase
121
101
 
122
102
  context "reload" do
123
103
  setup do
124
- @foo = Foo.create :x => 'hello', :y => true
104
+ @foo = Foo.create('cx', :x => 'hello', :y => true)
125
105
  end
126
106
 
127
107
  should "reload all properties" do
128
- redis.set @foo.key, %q({"x":23,"y":"adios"})
108
+ redis.hset @foo.context, @foo.key, %q({"x":23,"y":"adios"})
129
109
  @foo.reload
130
110
  assert_equal 23, @foo.x
131
111
  assert_equal 'adios', @foo.y
@@ -144,19 +124,19 @@ class TestEntity < Test::Unit::TestCase
144
124
  end
145
125
 
146
126
  should "raise EntityNotFound if the entity does not exist any more" do
147
- redis.del @foo.key
127
+ redis.hdel @foo.context, @foo.key
148
128
  assert_raise(Remodel::EntityNotFound) { @foo.reload }
149
129
  end
150
130
 
151
131
  should "raise EntityNotSaved if the entity was never saved" do
152
- assert_raise(Remodel::EntityNotSaved) { Foo.new.reload }
132
+ assert_raise(Remodel::EntityNotSaved) { Foo.new('cx').reload }
153
133
  end
154
134
  end
155
135
 
156
136
  context "update" do
157
137
  setup do
158
138
  redis.flushdb
159
- @foo = Foo.create :x => 'Tim', :y => true
139
+ @foo = Foo.create('cx', :x => 'Tim', :y => true)
160
140
  end
161
141
 
162
142
  should "set the given properties" do
@@ -173,25 +153,9 @@ class TestEntity < Test::Unit::TestCase
173
153
  end
174
154
  end
175
155
 
176
- context "delete" do
177
- setup do
178
- redis.flushdb
179
- @foo = Foo.create :x => 'Tim', :y => true
180
- end
181
-
182
- should "delete the given entity" do
183
- @foo.delete
184
- assert_nil redis.get(@foo.key)
185
- end
186
-
187
- should "ensure that the entity is persistent" do
188
- assert_raise(Remodel::EntityNotSaved) { Foo.new.delete }
189
- end
190
- end
191
-
192
156
  context "to_json" do
193
157
  should "serialize to json" do
194
- foo = Foo.new :x => 42, :y => true
158
+ foo = Foo.new('cx', :x => 42, :y => true)
195
159
  assert_match /"x":42/, foo.to_json
196
160
  assert_match /"y":true/, foo.to_json
197
161
  end
@@ -199,7 +163,7 @@ class TestEntity < Test::Unit::TestCase
199
163
 
200
164
  context "as_json" do
201
165
  should "serialize into a hash" do
202
- foo = Foo.create :x => 42, :y => true
166
+ foo = Foo.create('cx', :x => 42, :y => true)
203
167
  expected = { :id => foo.id, :x => 42, :y => true }
204
168
  assert_equal expected, foo.as_json
205
169
  end
@@ -208,7 +172,7 @@ class TestEntity < Test::Unit::TestCase
208
172
  context "#set_key_prefix" do
209
173
  should "use the given key prefix" do
210
174
  class Custom < Remodel::Entity; set_key_prefix 'my'; end
211
- assert_match /^my:\d+$/, Custom.create.key
175
+ assert_match /^my\d+$/, Custom.create('cx').key
212
176
  end
213
177
 
214
178
  should "ensure that the prefix is letters only" do
@@ -221,47 +185,34 @@ class TestEntity < Test::Unit::TestCase
221
185
  context "#find" do
222
186
  setup do
223
187
  redis.flushdb
224
- @foo = Foo.create :x => 'hello', :y => 123
225
- Foo.create :x => 'hallo', :y => 124
188
+ @foo = Foo.create('cx', :x => 'hello', :y => 123)
189
+ Foo.create('cx', :x => 'hallo', :y => 124)
226
190
  end
227
191
 
228
192
  should "find and load an entity by key" do
229
- foo = Foo.find(@foo.key)
193
+ foo = Foo.find(@foo.context, @foo.key)
230
194
  assert_equal foo.x, @foo.x
231
195
  assert_equal foo.y, @foo.y
232
196
  end
233
197
 
234
198
  should "find and load an entity by id" do
235
- foo = Foo.find(@foo.id)
199
+ foo = Foo.find(@foo.context, @foo.id)
236
200
  assert_equal foo.x, @foo.x
237
201
  assert_equal foo.y, @foo.y
238
202
  end
239
203
 
240
204
  should "reject a key which does not exist" do
241
- assert_raise(Remodel::EntityNotFound) { Foo.find('x:66') }
205
+ assert_raise(Remodel::EntityNotFound) { Foo.find('cx', 'x66') }
242
206
  end
243
207
 
244
208
  should "reject an id which does not exist" do
245
- assert_raise(Remodel::EntityNotFound) { Foo.find(66) }
246
- end
247
- end
248
-
249
- context "#all" do
250
- setup do
251
- redis.flushdb
252
- 17.times { |i| Foo.create :x => 'hello', :y => i }
253
- 5.times { |i| Bar.create }
254
- end
255
-
256
- should "find all entities of the given class" do
257
- assert_equal 17, Foo.all.size
258
- assert_equal 5, Bar.all.size
209
+ assert_raise(Remodel::EntityNotFound) { Foo.find('cx', 66) }
259
210
  end
260
211
  end
261
212
 
262
213
  context "properties" do
263
214
  should "have property x" do
264
- foo = Foo.new
215
+ foo = Foo.new('cx')
265
216
  foo.x = 23
266
217
  assert_equal 23, foo.x
267
218
  foo.x += 10
@@ -269,45 +220,45 @@ class TestEntity < Test::Unit::TestCase
269
220
  end
270
221
 
271
222
  should "not have property z" do
272
- foo = Foo.new
223
+ foo = Foo.new('cx')
273
224
  assert_raise(NoMethodError) { foo.z }
274
225
  assert_raise(NoMethodError) { foo.z = 42 }
275
226
  end
276
227
 
277
228
  context "types" do
278
229
  should "work with nil" do
279
- foo = Foo.create :x => nil
230
+ foo = Foo.create('cx', :x => nil)
280
231
  assert_equal nil, foo.reload.x
281
232
  end
282
233
 
283
234
  should "work with booleans" do
284
- foo = Foo.create :x => false
235
+ foo = Foo.create('cx', :x => false)
285
236
  assert_equal false, foo.reload.x
286
237
  end
287
238
 
288
239
  should "work with integers" do
289
- foo = Foo.create :x => -42
240
+ foo = Foo.create('cx', :x => -42)
290
241
  assert_equal -42, foo.reload.x
291
242
  end
292
243
 
293
244
  should "work with floats" do
294
- foo = Foo.create :x => 3.141
245
+ foo = Foo.create('cx', :x => 3.141)
295
246
  assert_equal 3.141, foo.reload.x
296
247
  end
297
248
 
298
249
  should "work with strings" do
299
- foo = Foo.create :x => 'hello'
250
+ foo = Foo.create('cx', :x => 'hello')
300
251
  assert_equal 'hello', foo.reload.x
301
252
  end
302
253
 
303
254
  should "work with lists" do
304
- foo = Foo.create :x => [1, 2, 3]
255
+ foo = Foo.create('cx', :x => [1, 2, 3])
305
256
  assert_equal [1, 2, 3], foo.reload.x
306
257
  end
307
258
 
308
259
  should "work with hashes" do
309
260
  hash = { 'a' => 17, 'b' => 'test' }
310
- foo = Foo.create :x => hash
261
+ foo = Foo.create('cx', :x => hash)
311
262
  assert_equal hash, foo.reload.x
312
263
  end
313
264
  end
@@ -315,8 +266,8 @@ class TestEntity < Test::Unit::TestCase
315
266
 
316
267
  context "#restore" do
317
268
  should "restore an entity from json" do
318
- before = Foo.create :x => 42, :y => true
319
- after = Foo.restore(before.key, before.to_json)
269
+ before = Foo.create('cx', :x => 42, :y => true)
270
+ after = Foo.restore(before.context, before.key, before.to_json)
320
271
  assert_equal before.key, after.key
321
272
  assert_equal before.x, after.x
322
273
  assert_equal before.y, after.y
@@ -0,0 +1,55 @@
1
+ require 'helper'
2
+
3
+ class TestEntityDefaults < Test::Unit::TestCase
4
+
5
+ class Bar < Remodel::Entity
6
+ property :simple, :default => 123
7
+ property :array, :default => [1]
8
+ property :hash, :default => { :foo => 1 }
9
+ end
10
+
11
+ context "[default values]" do
12
+ should "be returned for missing properties" do
13
+ bar = Bar.new('cx')
14
+ assert_equal 123, bar.simple
15
+ end
16
+
17
+ should "be returned for properties that are nil" do
18
+ bar = Bar.new('cx', :simple => 'cool')
19
+ bar.simple = nil
20
+ assert_equal 123, bar.simple
21
+ end
22
+
23
+ should "not be returned for given properties" do
24
+ bar = Bar.new('cx', :simple => 'cool')
25
+ assert_equal 'cool', bar.simple
26
+ end
27
+
28
+ should "not be stored" do
29
+ bar = Bar.create('cx')
30
+ assert !(/123/ =~ redis.hget('cx', bar.key))
31
+ end
32
+
33
+ should "be returned by as_json" do
34
+ bar = Bar.new('cx')
35
+ assert_equal 123, bar.as_json[:simple]
36
+ end
37
+ end
38
+
39
+ context "[collections]" do
40
+ setup do
41
+ @bar, @baz = Bar.new('cx'), Bar.new('cx')
42
+ end
43
+
44
+ should "not share arrays" do
45
+ @bar.array[0] += 1
46
+ assert_equal [1], @baz.array
47
+ end
48
+
49
+ should "not share hashes" do
50
+ @bar.hash[:foo] = 42
51
+ assert_equal 1, @baz.hash[:foo]
52
+ end
53
+ end
54
+
55
+ end
@@ -0,0 +1,61 @@
1
+ require 'helper'
2
+
3
+ class TestEntityDelete < Test::Unit::TestCase
4
+
5
+ class Group < Remodel::Entity
6
+ has_many :members, :class => 'TestEntityDelete::Person'
7
+ has_one :room, :class => 'TestEntityDelete::Room'
8
+ property :name
9
+ end
10
+
11
+ class Person < Remodel::Entity
12
+ property :name
13
+ end
14
+
15
+ class Room < Remodel::Entity
16
+ property :name
17
+ end
18
+
19
+ context "delete" do
20
+ setup do
21
+ redis.flushdb
22
+ @group = Group.create('cx', :name => 'ruby user group')
23
+ @tim = @group.members.create(:name => 'Tim')
24
+ @group.members.create(:name => 'Ben')
25
+ @room = Room.create(:name => 'some office')
26
+ @group.room = @room
27
+ @group.reload
28
+ end
29
+
30
+ should "ensure that the entity is persistent" do
31
+ assert_raise(Remodel::EntityNotSaved) { Group.new('cx').delete }
32
+ end
33
+
34
+ should "delete the given entity" do
35
+ @group.delete
36
+ assert_nil redis.hget(@group.context, @group.key)
37
+ end
38
+
39
+ should "delete any associations in redis" do
40
+ @group.delete
41
+ assert_nil redis.hget(@group.context, "#{@group.key}_members")
42
+ assert_nil redis.hget(@group.context, "#{@group.key}_room")
43
+ end
44
+
45
+ context "has_one" do
46
+ should "be nil if deleted" do
47
+ @room.delete
48
+ assert_nil @group.room
49
+ end
50
+ end
51
+
52
+ context "has_many" do
53
+ should "be skipped if deleted" do
54
+ @tim.delete
55
+ assert_equal 1, @group.members.count
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -14,19 +14,19 @@ class TestManyToMany < Test::Unit::TestCase
14
14
 
15
15
  context "both associations" do
16
16
  should "be empty by default" do
17
- assert_equal [], Person.new.groups
18
- assert_equal [], Group.new.members
17
+ assert_equal [], Person.new('cx').groups
18
+ assert_equal [], Group.new('cx').members
19
19
  end
20
20
 
21
21
  context "create" do
22
22
  should "add a new group to both associations" do
23
- tim = Person.create :name => 'tim'
23
+ tim = Person.create('cx', :name => 'tim')
24
24
  rugb = tim.groups.create :name => 'rug-b'
25
25
  assert_equal [tim], rugb.members
26
26
  end
27
27
 
28
28
  should "add a new person to both associations" do
29
- rugb = Group.create :name => 'rug-b'
29
+ rugb = Group.create('cx', :name => 'rug-b')
30
30
  tim = rugb.members.create :name => 'tim'
31
31
  assert_equal [rugb], tim.groups
32
32
  end
@@ -34,8 +34,8 @@ class TestManyToMany < Test::Unit::TestCase
34
34
 
35
35
  context "add" do
36
36
  setup do
37
- @tim = Person.create :name => 'tim'
38
- @rugb = Group.create :name => 'rug-b'
37
+ @tim = Person.create('cx', :name => 'tim')
38
+ @rugb = Group.create('cx', :name => 'rug-b')
39
39
  end
40
40
 
41
41
  should "add a new group to both associations" do
@@ -53,7 +53,7 @@ class TestManyToMany < Test::Unit::TestCase
53
53
 
54
54
  context "remove" do
55
55
  setup do
56
- @tim = Person.create :name => 'tim'
56
+ @tim = Person.create('cx', :name => 'tim')
57
57
  @rugb = @tim.groups.create(:name => 'rug-b')
58
58
  @erlang = @tim.groups.create(:name => 'erlang')
59
59
  @aws = @tim.groups.create(:name => 'aws')
@@ -1,4 +1,5 @@
1
1
  require 'helper'
2
+ require 'json'
2
3
 
3
4
  class TestManyToOne < Test::Unit::TestCase
4
5
 
@@ -15,35 +16,47 @@ class TestManyToOne < Test::Unit::TestCase
15
16
  context "has_many" do
16
17
  context "association" do
17
18
  should "exist" do
18
- assert Puzzle.create.respond_to?(:pieces)
19
+ assert Puzzle.create('cx').respond_to?(:pieces)
19
20
  end
20
21
 
21
22
  should "return an empty list by default" do
22
- assert_equal [], Puzzle.create.pieces
23
+ assert_equal [], Puzzle.create('cx').pieces
23
24
  end
24
-
25
+
25
26
  should "return any existing children" do
26
- puzzle = Puzzle.create
27
- redis.rpush "#{puzzle.key}:pieces", Piece.create(:color => 'red').key
28
- redis.rpush "#{puzzle.key}:pieces", Piece.create(:color => 'blue').key
27
+ puzzle = Puzzle.create('cx')
28
+ red_piece = Piece.create('cx', :color => 'red')
29
+ blue_piece = Piece.create('cx', :color => 'blue')
30
+ value = JSON.generate([red_piece.key, blue_piece.key])
31
+ redis.hset 'cx', "#{puzzle.key}_pieces", value
29
32
  assert_equal 2, puzzle.pieces.size
30
33
  assert_equal Piece, puzzle.pieces[0].class
31
34
  assert_equal 'red', puzzle.pieces[0].color
32
35
  end
33
36
 
37
+ should "not return any child multiple times" do
38
+ puzzle = Puzzle.create('cx')
39
+ red_piece = Piece.create('cx', :color => 'red')
40
+ value = JSON.generate([red_piece.key, red_piece.key])
41
+ redis.hset 'cx', "#{puzzle.key}_pieces", value
42
+ assert_equal 1, puzzle.pieces.size
43
+ assert_equal Piece, puzzle.pieces[0].class
44
+ assert_equal 'red', puzzle.pieces[0].color
45
+ end
46
+
34
47
  context "create" do
35
48
  should "have a create method" do
36
- assert Puzzle.create.pieces.respond_to?(:create)
49
+ assert Puzzle.create('cx').pieces.respond_to?(:create)
37
50
  end
38
51
 
39
52
  should "work without attributes" do
40
- puzzle = Puzzle.create
53
+ puzzle = Puzzle.create('cx')
41
54
  piece = puzzle.pieces.create
42
55
  assert piece.is_a?(Piece)
43
56
  end
44
57
 
45
58
  should "create and store a new child" do
46
- puzzle = Puzzle.create
59
+ puzzle = Puzzle.create('cx')
47
60
  puzzle.pieces.create :color => 'green'
48
61
  assert_equal 1, puzzle.pieces.size
49
62
  puzzle.reload
@@ -53,7 +66,7 @@ class TestManyToOne < Test::Unit::TestCase
53
66
  end
54
67
 
55
68
  should "associate the created child with self" do
56
- puzzle = Puzzle.create :topic => 'provence'
69
+ puzzle = Puzzle.create('cx', :topic => 'provence')
57
70
  piece = puzzle.pieces.create :color => 'green'
58
71
  assert_equal 'provence', piece.puzzle.topic
59
72
  end
@@ -61,8 +74,8 @@ class TestManyToOne < Test::Unit::TestCase
61
74
 
62
75
  context "add" do
63
76
  should "add the given entity to the association" do
64
- puzzle = Puzzle.create
65
- piece = Piece.create :color => 'white'
77
+ puzzle = Puzzle.create('cx')
78
+ piece = Piece.create('cx', :color => 'white')
66
79
  puzzle.pieces.add piece
67
80
  assert_equal 1, puzzle.pieces.size
68
81
  puzzle.reload
@@ -74,7 +87,7 @@ class TestManyToOne < Test::Unit::TestCase
74
87
 
75
88
  context "find" do
76
89
  setup do
77
- @puzzle = Puzzle.create
90
+ @puzzle = Puzzle.create('cx')
78
91
  5.times { @puzzle.pieces.create :color => 'blue' }
79
92
  end
80
93
 
@@ -93,9 +106,9 @@ class TestManyToOne < Test::Unit::TestCase
93
106
 
94
107
  context "reload" do
95
108
  should "reset has_many associations" do
96
- puzzle = Puzzle.create
109
+ puzzle = Puzzle.create('cx')
97
110
  piece = puzzle.pieces.create :color => 'black'
98
- redis.del "#{puzzle.key}:pieces"
111
+ redis.hdel 'cx', "#{puzzle.key}_pieces"
99
112
  puzzle.reload
100
113
  assert_equal [], puzzle.pieces
101
114
  end
data/test/test_mappers.rb CHANGED
@@ -15,7 +15,7 @@ class TestMappers < Test::Unit::TestCase
15
15
 
16
16
  context "create" do
17
17
  setup do
18
- @item = Item.create :time => Time.at(1234567890), :date => Date.parse("1972-06-16")
18
+ @item = Item.create('cx', :time => Time.at(1234567890), :date => Date.parse("1972-06-16"))
19
19
  end
20
20
 
21
21
  should "store unmapped values" do
@@ -35,13 +35,13 @@ class TestMappers < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  should "serialize mapped values correctly" do
38
- json = redis.get(@item.key)
38
+ json = redis.hget(@item.context, @item.key)
39
39
  assert_match /1234567890/, json
40
40
  assert_match /"1972-06-16"/, json
41
41
  end
42
42
 
43
43
  should "handle nil values" do
44
- item = Item.create
44
+ item = Item.create('cx')
45
45
  assert_nil item.boolean
46
46
  assert_nil item.string
47
47
  assert_nil item.integer
@@ -53,14 +53,14 @@ class TestMappers < Test::Unit::TestCase
53
53
  end
54
54
 
55
55
  should "reject invalid types" do
56
- assert_raise(Remodel::InvalidType) { Item.create :boolean => 'hello' }
57
- assert_raise(Remodel::InvalidType) { Item.create :string => true }
58
- assert_raise(Remodel::InvalidType) { Item.create :integer => 33.5 }
59
- assert_raise(Remodel::InvalidType) { Item.create :float => 5 }
60
- assert_raise(Remodel::InvalidType) { Item.create :array => {} }
61
- assert_raise(Remodel::InvalidType) { Item.create :hash => [] }
62
- assert_raise(Remodel::InvalidType) { Item.create :time => Date.new }
63
- assert_raise(Remodel::InvalidType) { Item.create :date => Time.now }
56
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :boolean => 'hello') }
57
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :string => true) }
58
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :integer => 33.5) }
59
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :float => 5) }
60
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :array => {}) }
61
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :hash => []) }
62
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :time => Date.new) }
63
+ assert_raise(Remodel::InvalidType) { Item.create('cx', :date => Time.now) }
64
64
  end
65
65
  end
66
66