static_model 0.2.2 → 0.2.3

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.
@@ -1,427 +1,472 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestStaticModel < Test::Unit::TestCase
4
-
5
- context "StaticModel" do
6
- context "A class that inherits from Base" do
7
- context "an instance" do
8
-
9
- setup do
10
- @book = Book.new(book_params)
11
- end
12
-
13
- context "initialization" do
14
-
15
- should "set attributes with a hash" do
16
- assert @book.id
17
- end
18
-
19
- should "raise error if passed anything but hash" do
20
- assert_raise(StaticModel::BadOptions) do
21
- Book.new("im bad")
22
- end
23
- end
24
- end
25
-
26
- context "attributes" do
27
- should "get attributes by methods" do
28
- assert_equal book_params[:title], @book.title
29
- assert_equal book_params[:genre], @book.genre
30
- end
31
-
32
- should "set attributes by methods" do
33
- @book.title = 'New Title'
34
- assert_equal 'New Title', @book.title
35
- end
36
- end
37
-
38
- context "to_s" do
39
- should "inspect" do
40
- assert_equal @book.inspect, @book.to_s
41
- end
42
- end
43
-
44
- context "comparing" do
45
-
46
- should "be equal to an instance of the same class with same id" do
47
- assert_equal @book, Book.new(book_params)
48
- end
49
-
50
- should "not be equal to an instance with the same class with different ids" do
51
- assert_not_equal Book[1], @book
52
- end
53
-
54
- should "not be equal to an instance with different classes and the same ids" do
55
- assert_not_equal Book[1], Author[1]
56
- end
57
- end
58
-
59
- end
60
-
61
- context "on the class" do
62
- context "set data file" do
63
- context "After the class is defined" do
64
-
65
- setup do
66
- @book = Book.find(1)
67
- @author = Author.find(1)
68
- @original_data_file = Book.data_file
69
- @data_file = File.join(File.dirname(__FILE__), 'data', 'authors.yml')
70
- Book.set_data_file @data_file
71
- @new_book = Book.find(1)
72
- end
73
-
74
- should "set the @data_file" do
75
- assert_equal @data_file, Book.data_file
76
- end
77
-
78
- should "reload with next find" do
79
- assert @author.attributes, @new_book.attributes
80
- end
81
-
82
- teardown do
83
- Book.set_data_file @original_data_file
84
- end
85
- end
86
- end
87
-
88
- context "next_id" do
89
- context "if id's were automaticaly assigned" do
90
- should "be length + 1" do
91
- Store.load
92
- assert_equal Store.count + 1, Store.next_id
93
- end
94
- end
95
-
96
- context "if ids were manualy assigned" do
97
- should "be 1 after the last id" do
98
- Publisher.load
99
- assert_equal 8, Publisher.next_id
100
- end
101
- end
102
- end
103
-
104
- context "where the records are defined without ids" do
105
- setup do
106
- Store.reload!
107
- end
108
-
109
- context "loading" do
110
- setup do
111
- @stores = Store.all
112
- end
113
-
114
- should "automaticaly assign ids" do
115
- @stores.each do |store|
116
- assert store.id
117
- assert store.id.is_a?(Fixnum)
118
- end
119
- end
120
-
121
- should "assign next id" do
122
- assert Store.next_id
123
- assert_equal 3, Store.next_id
124
- end
125
- end
126
-
127
- context "initializing without id" do
128
- setup do
129
- @store = Store.new({:name => 'Metro Comics', :city => 'New York'})
130
- end
131
-
132
- should "return instance" do
133
- assert @store.is_a?(Store)
134
- end
135
-
136
- should "set attributes" do
137
- assert_equal 'New York', @store.city
138
- end
139
-
140
- should "assign id from next id" do
141
- assert_equal 3, @store.id
142
- end
143
-
144
- should "increment next_id" do
145
- assert_equal 4, Store.next_id
146
- end
147
-
148
- end
149
- end
150
-
151
- context "loading a data_file with embedded erb" do
152
- setup do
153
- @projects = Project.all
154
- end
155
-
156
- should "evaluate erb expressions at load time" do
157
- assert_equal 1.day.ago.strftime('%m/%d/%Y %I:%M%p'), @projects.first.created_at
158
- end
159
-
160
- should "evaluate erb in current context" do
161
- assert_equal Author.first, @projects[1].author
162
- end
163
- end
164
-
165
- context "find" do
166
-
167
- context "with an integer" do
168
- setup do
169
- @book = Book.find(1)
170
- end
171
-
172
- should "set loaded?" do
173
- assert Book.loaded?
174
- end
175
-
176
- should "load by id" do
177
- assert_equal 1, @book.id
178
- end
179
-
180
- should "return instance of klass" do
181
- assert @book.is_a?(Book)
182
- end
183
-
184
- should "raise error if cant find record with id" do
185
- assert_raise(StaticModel::RecordNotFound) do
186
- @book = Book.find(1000)
187
- end
188
- end
189
- end
190
- end
191
-
192
- context "[]" do
193
- should "be an alias for find by id" do
194
- assert_equal Book.find(1), Book[1]
195
- end
196
- end
197
-
198
- context "find(:all)" do
199
- should "be an alias for find_all" do
200
- assert_equal Book.find_all, Book.find(:all)
201
- end
202
- end
203
- context "find(:first)" do
204
- should "be an alias for find_first" do
205
- assert_equal Book.find_first, Book.find(:first)
206
- end
207
- end
208
-
209
- context "all" do
210
- should "be an alias for find_all" do
211
- assert_equal Book.all, Book.find(:all)
212
- end
213
- end
214
- context "first" do
215
- should "be an alias for find_first" do
216
- assert_equal Book.first, Book.find(:first)
217
- end
218
- end
219
-
220
- context "find_first" do
221
- setup do
222
- @book = Book.find_first
223
- end
224
-
225
- should "return the first instance from all records" do
226
- assert_equal Book.find_all.first, @book
227
- end
228
-
229
- should "return instance of klass" do
230
- assert @book.is_a?(Book)
231
- end
232
- end
233
-
234
- context "find_all" do
235
- setup do
236
- @books = Book.find_all
237
- end
238
-
239
- should "return an array" do
240
- assert @books.is_a?(Array)
241
- end
242
-
243
- should "return all records" do
244
- assert_equal 4, @books.length
245
- end
246
-
247
- should "return set of klass instances" do
248
- @books.each do |book|
249
- assert book.is_a?(Book)
250
- end
251
- end
252
-
253
- context "with an empty data file" do
254
- setup do
255
- @original_data_file = Book.data_file
256
- @data_file = File.join(File.dirname(__FILE__), 'data', 'empty.yml')
257
- Book.set_data_file @data_file
258
- end
259
-
260
- should "return an empty array" do
261
- assert_equal [], Book.find_all
262
- end
263
-
264
- teardown do
265
- Book.set_data_file @original_data_file
266
- end
267
-
268
- end
269
- end
270
-
271
- context "find_first_by" do
272
- setup do
273
- @author = 'Michael Pollan'
274
- @book = Book.find_first_by(:author,@author)
275
- end
276
-
277
- should "return an instance of klass" do
278
- assert @book.is_a?(Book)
279
- end
280
-
281
- should "return record matching search" do
282
- assert @author, @book.author
283
- end
284
-
285
- context "when there is no match" do
286
- should "return nil" do
287
- assert_nil Book.find_first_by(:author,'Aaron Quint')
288
- end
289
- end
290
- end
291
-
292
- context "find_by" do
293
- setup do
294
- @author = 'Michael Pollan'
295
- @book = Book.find_by(:author,@author)
296
- end
297
-
298
- should "return an instance of klass" do
299
- assert @book.is_a?(Book)
300
- end
301
-
302
- should "return record matching search" do
303
- assert @author, @book.author
304
- end
305
-
306
- context "when there is no match" do
307
- should "return nil" do
308
- assert_nil Book.find_by(:author,'Aaron Quint')
309
- end
310
- end
311
-
312
- end
313
-
314
- context "find_all_by" do
315
- setup do
316
- @author = 'Michael Pollan'
317
- @books = Book.find_all_by(:author,@author)
318
- end
319
-
320
- should "return an array" do
321
- assert @books.is_a?(Array)
322
- end
323
-
324
- should "return all records that match search" do
325
- @books.each {|b| assert_equal @author, b.author}
326
- end
327
-
328
- should "return set of klass instances" do
329
- @books.each {|b| assert b.is_a?(Book) }
330
- end
331
-
332
- context "when there is no match" do
333
- should "return an empty array" do
334
- assert_equal [], Book.find_all_by(:author,'Aaron Quint')
335
- end
336
- end
337
- context "when there is only one match" do
338
- should "return an array" do
339
- assert_equal [Book.find(3)], Book.find_all_by(:author,'Piers Anthony')
340
- end
341
- end
342
- end
343
-
344
- context "dynamic finders" do
345
- setup do
346
- @book = Book.first
347
- end
348
-
349
- context "find_by_*attribute*" do
350
- should "be equivalent to find_first_by(attribute,)" do
351
- assert_equal @book, Book.find_first_by(:genre, 'Non-Fiction')
352
- assert_equal Book.find_first_by(:genre, 'Non-Fiction'), Book.find_by_genre('Non-Fiction')
353
- end
354
- end
355
-
356
- context "find_first_by_*attribute*" do
357
- should "be equivalent to find_first_by(attribute,)" do
358
- assert_equal @book, Book.find_first_by(:genre, 'Non-Fiction')
359
- assert_equal Book.find_first_by(:genre, 'Non-Fiction'), Book.find_first_by_genre('Non-Fiction')
360
- end
361
- end
362
-
363
- context "find_all_by_*attribute*" do
364
- should "be equivalent to find_all_by(attribute,)" do
365
- assert_equal Book.find_all_by(:genre, 'Non-Fiction'), Book.find_all_by_genre('Non-Fiction')
366
- end
367
- end
368
- end
369
-
370
- context "count" do
371
- should "return the count of all records" do
372
- assert_equal Book.all.length, Book.count
373
- end
374
- end
375
-
376
- context "with a class with yaml class vars" do
377
- setup do
378
- @pages = Page.all
379
- end
380
-
381
- should "load :records into @records" do
382
- assert_set_of Page, @pages
383
- assert Page.loaded?
384
- end
385
-
386
- should "give access to top level attributes as class methods" do
387
- assert_equal 'http://www.quirkey.com', Page.url
388
- assert_equal 'The Best Ever', Page.title
389
- end
390
-
391
- should "return a hash for class attribute" do
392
- assert Page.settings.is_a?(Hash)
393
- assert_equal 'test', Page.settings['username']
394
- end
395
-
396
- should "have class attributes appear as record accessor defaults if none exist" do
397
- assert_equal 'http://www.quirkey.com', Page[1].url
398
- end
399
-
400
- should "not overwrite record specific methods" do
401
- assert_equal 'http://github.com', Page[2].url
402
- end
403
-
404
- context "class_attributes" do
405
- setup do
406
- @attributes = Page.class_attributes
407
- end
408
-
409
- should "return a hash of all top level settings" do
410
- assert @attributes.is_a?(Hash)
411
- assert_equal 3, @attributes.length
412
- assert_equal 'http://www.quirkey.com', @attributes['url']
413
- end
414
- end
415
- end
416
-
417
- end
418
- end
419
- end
420
-
421
- protected
422
- def book_params
423
- {:id => 15, :title => 'Lord of the Rings', :author => 'J.R. Tolkien', :genre => 'Fantasy'}
424
- end
425
-
426
-
427
- end
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestStaticModel < Test::Unit::TestCase
4
+
5
+ context "StaticModel" do
6
+ context "A class that inherits from Base" do
7
+ context "an instance" do
8
+
9
+ setup do
10
+ @book = Book.new(book_params)
11
+ end
12
+
13
+ context "initialization" do
14
+
15
+ should "set attributes with a hash" do
16
+ assert @book.id
17
+ end
18
+
19
+ should "raise error if passed anything but hash" do
20
+ assert_raise(StaticModel::BadOptions) do
21
+ Book.new("im bad")
22
+ end
23
+ end
24
+ end
25
+
26
+ context "attributes" do
27
+ should "get attributes by methods" do
28
+ assert_equal book_params[:title], @book.title
29
+ assert_equal book_params[:genre], @book.genre
30
+ end
31
+
32
+ should "set attributes by methods" do
33
+ @book.title = 'New Title'
34
+ assert_equal 'New Title', @book.title
35
+ end
36
+ end
37
+
38
+ context "to_s" do
39
+ should "inspect" do
40
+ assert_equal @book.inspect, @book.to_s
41
+ end
42
+ end
43
+
44
+ context "comparing" do
45
+
46
+ should "be equal to an instance of the same class with same id" do
47
+ assert_equal @book, Book.new(book_params)
48
+ end
49
+
50
+ should "not be equal to an instance with the same class with different ids" do
51
+ assert_not_equal Book[1], @book
52
+ end
53
+
54
+ should "not be equal to an instance with different classes and the same ids" do
55
+ assert_not_equal Book[1], Author[1]
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ context "on the class" do
62
+ context "set data file" do
63
+ context "After the class is defined" do
64
+
65
+ setup do
66
+ @book = Book.find(1)
67
+ @author = Author.find(1)
68
+ @original_data_file = Book.data_file
69
+ @data_file = File.join(File.dirname(__FILE__), 'data', 'authors.yml')
70
+ Book.set_data_file @data_file
71
+ @new_book = Book.find(1)
72
+ end
73
+
74
+ should "set the @data_file" do
75
+ assert_equal @data_file, Book.data_file
76
+ end
77
+
78
+ should "reload with next find" do
79
+ assert @author.attributes, @new_book.attributes
80
+ end
81
+
82
+ teardown do
83
+ Book.set_data_file @original_data_file
84
+ end
85
+ end
86
+ end
87
+
88
+ context "next_id" do
89
+ context "if id's were automaticaly assigned" do
90
+ should "be length + 1" do
91
+ Store.load
92
+ assert_equal Store.count + 1, Store.next_id
93
+ end
94
+ end
95
+
96
+ context "if ids were manualy assigned" do
97
+ should "be 1 after the last id" do
98
+ Publisher.load
99
+ assert_equal 8, Publisher.next_id
100
+ end
101
+ end
102
+ end
103
+
104
+ context "where the records are defined without ids" do
105
+ setup do
106
+ Store.reload!
107
+ end
108
+
109
+ context "loading" do
110
+ setup do
111
+ @stores = Store.all
112
+ end
113
+
114
+ should "automaticaly assign ids" do
115
+ @stores.each do |store|
116
+ assert store.id
117
+ assert store.id.is_a?(Fixnum)
118
+ end
119
+ end
120
+
121
+ should "assign next id" do
122
+ assert Store.next_id
123
+ assert_equal 3, Store.next_id
124
+ end
125
+ end
126
+
127
+ context "initializing without id" do
128
+ setup do
129
+ @store = Store.new({:name => 'Metro Comics', :city => 'New York'})
130
+ end
131
+
132
+ should "return instance" do
133
+ assert @store.is_a?(Store)
134
+ end
135
+
136
+ should "set attributes" do
137
+ assert_equal 'New York', @store.city
138
+ end
139
+
140
+ should "assign id from next id" do
141
+ assert_equal 3, @store.id
142
+ end
143
+
144
+ should "increment next_id" do
145
+ assert_equal 4, Store.next_id
146
+ end
147
+
148
+ end
149
+ end
150
+
151
+ context "loading a data_file with embedded erb" do
152
+ setup do
153
+ @projects = Project.all
154
+ end
155
+
156
+ should "evaluate erb expressions at load time" do
157
+ assert_equal 1.day.ago.strftime('%m/%d/%Y %I:%M%p'), @projects.first.created_at
158
+ end
159
+
160
+ should "evaluate erb in current context" do
161
+ assert_equal Author.first, @projects[1].author
162
+ end
163
+ end
164
+
165
+ context "find" do
166
+
167
+ context "with an integer" do
168
+ setup do
169
+ @book = Book.find(1)
170
+ end
171
+
172
+ should "set loaded?" do
173
+ assert Book.loaded?
174
+ end
175
+
176
+ should "load by id" do
177
+ assert_equal 1, @book.id
178
+ end
179
+
180
+ should "return instance of klass" do
181
+ assert @book.is_a?(Book)
182
+ end
183
+
184
+ should "raise error if cant find record with id" do
185
+ assert_raise(StaticModel::RecordNotFound) do
186
+ @book = Book.find(1000)
187
+ end
188
+ end
189
+ end
190
+ end
191
+
192
+ context "[]" do
193
+ should "be an alias for find by id" do
194
+ assert_equal Book.find(1), Book[1]
195
+ end
196
+ end
197
+
198
+ context "find(:all)" do
199
+ should "be an alias for find_all" do
200
+ assert_equal Book.find_all, Book.find(:all)
201
+ end
202
+ end
203
+ context "find(:first)" do
204
+ should "be an alias for find_first" do
205
+ assert_equal Book.find_first, Book.find(:first)
206
+ end
207
+ end
208
+ context "find(:last)" do
209
+ should "be an alias for find_last" do
210
+ assert_equal Book.find_last, Book.find(:last)
211
+ end
212
+ end
213
+
214
+ context "all" do
215
+ should "be an alias for find_all" do
216
+ assert_equal Book.all, Book.find(:all)
217
+ end
218
+ end
219
+ context "first" do
220
+ should "be an alias for find_first" do
221
+ assert_equal Book.first, Book.find(:first)
222
+ end
223
+ end
224
+ context "last" do
225
+ should "be an alias for find_last" do
226
+ assert_equal Book.last, Book.find(:last)
227
+ end
228
+ end
229
+
230
+ context "find_first" do
231
+ setup do
232
+ @book = Book.find_first
233
+ end
234
+
235
+ should "return the first instance from all records" do
236
+ assert_equal Book.find_all.first, @book
237
+ end
238
+
239
+ should "return instance of klass" do
240
+ assert @book.is_a?(Book)
241
+ end
242
+ end
243
+
244
+ context "find_last" do
245
+ setup do
246
+ @book = Book.find_last
247
+ end
248
+
249
+ should "return the last instance from all records" do
250
+ assert_equal Book.find_all.last, @book
251
+ end
252
+
253
+ should "return an instance of klass" do
254
+ assert @book.is_a?(Book)
255
+ end
256
+ end
257
+
258
+ context "find_all" do
259
+ setup do
260
+ @books = Book.find_all
261
+ end
262
+
263
+ should "return an array" do
264
+ assert @books.is_a?(Array)
265
+ end
266
+
267
+ should "return all records" do
268
+ assert_equal 4, @books.length
269
+ end
270
+
271
+ should "return set of klass instances" do
272
+ @books.each do |book|
273
+ assert book.is_a?(Book)
274
+ end
275
+ end
276
+
277
+ context "with an empty data file" do
278
+ setup do
279
+ @original_data_file = Book.data_file
280
+ @data_file = File.join(File.dirname(__FILE__), 'data', 'empty.yml')
281
+ Book.set_data_file @data_file
282
+ end
283
+
284
+ should "return an empty array" do
285
+ assert_equal [], Book.find_all
286
+ end
287
+
288
+ teardown do
289
+ Book.set_data_file @original_data_file
290
+ end
291
+
292
+ end
293
+ end
294
+
295
+ context "find_first_by" do
296
+ setup do
297
+ @author = 'Michael Pollan'
298
+ @book = Book.find_first_by(:author,@author)
299
+ end
300
+
301
+ should "return an instance of klass" do
302
+ assert @book.is_a?(Book)
303
+ end
304
+
305
+ should "return record matching search" do
306
+ assert @author, @book.author
307
+ end
308
+
309
+ context "when there is no match" do
310
+ should "return nil" do
311
+ assert_nil Book.find_first_by(:author,'Aaron Quint')
312
+ end
313
+ end
314
+ end
315
+
316
+ context "find_last_by" do
317
+ setup do
318
+ @author = 'Chuck Palahniuk'
319
+ @book = Book.find_last_by(:author, @author)
320
+ end
321
+
322
+ should "return an instance of klass" do
323
+ assert @book.is_a?(Book)
324
+ end
325
+
326
+ should "return record matching search" do
327
+ assert @author, @book.author
328
+ end
329
+
330
+ context "when there is no match" do
331
+ should "return nil" do
332
+ assert_nil Book.find_last_by(:author, 'Michael R. Bernstein')
333
+ end
334
+ end
335
+ end
336
+
337
+ context "find_by" do
338
+ setup do
339
+ @author = 'Michael Pollan'
340
+ @book = Book.find_by(:author,@author)
341
+ end
342
+
343
+ should "return an instance of klass" do
344
+ assert @book.is_a?(Book)
345
+ end
346
+
347
+ should "return record matching search" do
348
+ assert @author, @book.author
349
+ end
350
+
351
+ context "when there is no match" do
352
+ should "return nil" do
353
+ assert_nil Book.find_by(:author,'Aaron Quint')
354
+ end
355
+ end
356
+
357
+ end
358
+
359
+ context "find_all_by" do
360
+ setup do
361
+ @author = 'Michael Pollan'
362
+ @books = Book.find_all_by(:author,@author)
363
+ end
364
+
365
+ should "return an array" do
366
+ assert @books.is_a?(Array)
367
+ end
368
+
369
+ should "return all records that match search" do
370
+ @books.each {|b| assert_equal @author, b.author}
371
+ end
372
+
373
+ should "return set of klass instances" do
374
+ @books.each {|b| assert b.is_a?(Book) }
375
+ end
376
+
377
+ context "when there is no match" do
378
+ should "return an empty array" do
379
+ assert_equal [], Book.find_all_by(:author,'Aaron Quint')
380
+ end
381
+ end
382
+ context "when there is only one match" do
383
+ should "return an array" do
384
+ assert_equal [Book.find(3)], Book.find_all_by(:author,'Piers Anthony')
385
+ end
386
+ end
387
+ end
388
+
389
+ context "dynamic finders" do
390
+ setup do
391
+ @book = Book.first
392
+ end
393
+
394
+ context "find_by_*attribute*" do
395
+ should "be equivalent to find_first_by(attribute,)" do
396
+ assert_equal @book, Book.find_first_by(:genre, 'Non-Fiction')
397
+ assert_equal Book.find_first_by(:genre, 'Non-Fiction'), Book.find_by_genre('Non-Fiction')
398
+ end
399
+ end
400
+
401
+ context "find_first_by_*attribute*" do
402
+ should "be equivalent to find_first_by(attribute,)" do
403
+ assert_equal @book, Book.find_first_by(:genre, 'Non-Fiction')
404
+ assert_equal Book.find_first_by(:genre, 'Non-Fiction'), Book.find_first_by_genre('Non-Fiction')
405
+ end
406
+ end
407
+
408
+ context "find_all_by_*attribute*" do
409
+ should "be equivalent to find_all_by(attribute,)" do
410
+ assert_equal Book.find_all_by(:genre, 'Non-Fiction'), Book.find_all_by_genre('Non-Fiction')
411
+ end
412
+ end
413
+ end
414
+
415
+ context "count" do
416
+ should "return the count of all records" do
417
+ assert_equal Book.all.length, Book.count
418
+ end
419
+ end
420
+
421
+ context "with a class with yaml class vars" do
422
+ setup do
423
+ @pages = Page.all
424
+ end
425
+
426
+ should "load :records into @records" do
427
+ assert_set_of Page, @pages
428
+ assert Page.loaded?
429
+ end
430
+
431
+ should "give access to top level attributes as class methods" do
432
+ assert_equal 'http://www.quirkey.com', Page.url
433
+ assert_equal 'The Best Ever', Page.title
434
+ end
435
+
436
+ should "return a hash for class attribute" do
437
+ assert Page.settings.is_a?(Hash)
438
+ assert_equal 'test', Page.settings['username']
439
+ end
440
+
441
+ should "have class attributes appear as record accessor defaults if none exist" do
442
+ assert_equal 'http://www.quirkey.com', Page[1].url
443
+ end
444
+
445
+ should "not overwrite record specific methods" do
446
+ assert_equal 'http://github.com', Page[2].url
447
+ end
448
+
449
+ context "class_attributes" do
450
+ setup do
451
+ @attributes = Page.class_attributes
452
+ end
453
+
454
+ should "return a hash of all top level settings" do
455
+ assert @attributes.is_a?(Hash)
456
+ assert_equal 3, @attributes.length
457
+ assert_equal 'http://www.quirkey.com', @attributes['url']
458
+ end
459
+ end
460
+ end
461
+
462
+ end
463
+ end
464
+ end
465
+
466
+ protected
467
+ def book_params
468
+ {:id => 15, :title => 'Lord of the Rings', :author => 'J.R. Tolkien', :genre => 'Fantasy'}
469
+ end
470
+
471
+
472
+ end