elibri_onix_mocks 0.1.6 → 0.1.7

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.
@@ -7,6 +7,7 @@ require 'elibri_onix_generator'
7
7
  require 'elibri_onix_mocks/onix_helpers'
8
8
  require "elibri_onix_mocks/version"
9
9
  require 'elibri_onix_mocks/mocks/mock_method_missing'
10
+ require 'elibri_onix_mocks/mocks/product'
10
11
  require 'elibri_onix_mocks/mocks/xml_mocks'
11
12
  require 'elibri_onix_mocks/generators/xml_generator'
12
13
  require 'elibri_onix_mocks/xml_variant'
@@ -89,4 +89,4 @@ module Elibri
89
89
  }
90
90
 
91
91
  end
92
- end
92
+ end
@@ -0,0 +1,9 @@
1
+
2
+ module Elibri::ONIX::Generator::Product
3
+ HEIGHT_UNIT = 'mm'
4
+ WIDTH_UNIT = 'mm'
5
+ THICKNESS_UNIT = 'mm'
6
+ WEIGHT_UNIT = 'gr'
7
+ FILE_SIZE_UNIT = 'MB'
8
+ DURATION_UNIT = 'min'
9
+ end
@@ -29,28 +29,40 @@ module Elibri
29
29
  # Dla uproszczenia stub`ujemy większość funkcjonalności:
30
30
  extend Mocha::API
31
31
 
32
+ def defaults
33
+ {
34
+ :notification_type => stub('NotificationType', :onix_code => Elibri::ONIX::Dict::Release_3_0::NotificationType::CONFIRMED_ON_PUBLICATION),
35
+ :publishing_status_onix_code => Elibri::ONIX::Dict::Release_3_0::PublishingStatusCode::ACTIVE,
36
+ :public? => true,
37
+ :facsimiles => [],
38
+ :similar_products => [],
39
+ :state => "published",
40
+ :elibri_product_categories => [],
41
+ :product_availabilities => [],
42
+ :languages => [],
43
+ :other_texts => [],
44
+ :attachments => [],
45
+ :series_membership_kind => stub('SeriesMemebershipKind', :user_given? => false),
46
+ :authorship_kind => stub('AuthorshipKind', :user_given? => false, :collective? => false, :no_contributor? => true),
47
+ }
48
+ end
32
49
 
33
50
  # Najprostszy produkt, dla którego XML się waliduje przez RelaxNG
34
51
  def basic_product(options = {})
35
- opt = {:title => "Nielegalni",
36
- :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
37
- :ean => nil,
38
- :isbn_value => '9788324799992',
39
- :record_reference => "fdb8fa072be774d97a97",
40
- :facsimiles => [],
41
- :similar_products => [],
42
- :state => "published",
43
- :public? => true}.merge(options)
44
- mock("product") do |product|
45
- product.stubs(
46
- opt
47
- )
48
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
52
+ attributes = {
53
+ :title => "Nielegalni",
54
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
55
+ :ean => nil,
56
+ :isbn_value => '9788324799992',
57
+ :record_reference => "fdb8fa072be774d97a97",
58
+ }
59
+ attributes = defaults.merge(attributes).merge(options)
60
+ stub_everything("basic_product", attributes).extend(OnixHelpers::InstanceMethods)
49
61
  end
50
62
 
51
63
 
52
64
  def book_example(options = {})
53
- opt = {
65
+ attributes = {
54
66
  :state => "published",
55
67
  :public? => true,
56
68
  :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
@@ -76,12 +88,14 @@ module Elibri
76
88
  :number_of_illustrations => 32,
77
89
  :kind_of_book? => true,
78
90
  :kind_of_ebook? => true,
91
+ :digital? => true,
79
92
  :kind_of_audio? => true,
80
93
  :kind_of_map? => true,
81
94
  :kind_of_measurable? => true,
82
95
  #:map_scale => '20000',
83
96
  :elibri_product_category1_id => 1110,
84
97
  :elibri_product_category2_id => 491,
98
+ :elibri_product_categories => [],
85
99
  :deletion_text => 'Rekord miał sporo błędów',
86
100
  :sale_restricted? => true,
87
101
  :sale_restricted_for => 'sklep.gildia.pl',
@@ -104,7 +118,7 @@ module Elibri
104
118
  :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
105
119
  ).extend(MockMethodMissing)
106
120
  ],
107
- :or_title => "Tytuł oryginalny",
121
+ :original_title => "Tytuł oryginalny",
108
122
  :trade_title => "Tytuł handlowy",
109
123
  :vat => 5,
110
124
  :pkwiu => "58.11.1",
@@ -116,7 +130,7 @@ module Elibri
116
130
  :edition_statement => 'wyd. 3, poprawione',
117
131
  :languages => [stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT)],
118
132
  :other_texts => [
119
- stub('OtherText',
133
+ stub_everything('OtherText',
120
134
  :artificial_id => 137,
121
135
  :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
122
136
  :text => 'Recenzja książki',
@@ -125,7 +139,7 @@ module Elibri
125
139
  :exportable? => true,
126
140
  :is_a_review? => true,
127
141
  :resource_link => 'http://example'
128
- ).extend(MockMethodMissing)
142
+ )
129
143
  ],
130
144
  :series_membership_kind => stub('series_membership_kind', :user_given? => true),
131
145
  :series_memberships => [
@@ -174,16 +188,13 @@ module Elibri
174
188
  :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 10, :amount => 14.99, :vat => 7, :currency_code => 'PLN') ]
175
189
  ).extend(MockMethodMissing)
176
190
  ]
177
- }.merge(options)
178
- mock("product").tap do |product|
179
- product.stubs(
180
- opt
181
- )
182
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
191
+ }
192
+ attributes = defaults.merge(attributes).merge(options)
193
+ stub_everything("book_example", attributes).extend(OnixHelpers::InstanceMethods)
183
194
  end
184
195
 
185
196
  def onix_record_identifiers_example(options = {})
186
- opt = {
197
+ attributes = {
187
198
  :state => "published",
188
199
  :title => "Nielegalni",
189
200
  :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::BOOK,
@@ -200,17 +211,14 @@ module Elibri
200
211
  :nip => "527-22-62-432", :phone => "22 721 70 07", :email => "", :website => "www.olesiejuk.pl"),
201
212
  :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::WHOLESALER).extend(MockMethodMissing)
202
213
  ]
203
- }.merge(options)
204
- mock("product").tap do |product|
205
- product.stubs(
206
- opt
207
- )
208
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
214
+ }
215
+ attributes = defaults.merge(attributes).merge(options)
216
+ stub_everything("onix_record_identifiers_example", attributes).extend(OnixHelpers::InstanceMethods)
209
217
  end
210
218
 
211
219
 
212
220
  def onix_product_form_example(options = {})
213
- opt = {
221
+ attributes = {
214
222
  :title => "Nielegalni",
215
223
  :ean => nil,
216
224
  :isbn_value => '9788324799992',
@@ -220,17 +228,14 @@ module Elibri
220
228
  :state => "published",
221
229
  :public? => true,
222
230
  :product_availabilities => []
223
- }.merge(options)
224
- mock("product").tap do |product|
225
- product.stubs(
226
- opt
227
- )
228
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
231
+ }
232
+ attributes = defaults.merge(attributes).merge(options)
233
+ stub_everything("onix_product_form_example", attributes).extend(OnixHelpers::InstanceMethods)
229
234
  end
230
235
 
231
236
 
232
237
  def onix_epub_details_example(options = {})
233
- opt = {
238
+ attributes = {
234
239
  :title => "Nielegalni",
235
240
  :ean => nil,
236
241
  :isbn_value => '9788324799992',
@@ -241,31 +246,25 @@ module Elibri
241
246
  :state => "published",
242
247
  :public? => true,
243
248
  :product_availabilities => []
244
- }.merge(options)
245
- mock("product").tap do |product|
246
- product.stubs(
247
- opt
248
- )
249
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
249
+ }
250
+ attributes = defaults.merge(attributes).merge(options)
251
+ stub_everything("onix_epub_details_example", attributes).extend(OnixHelpers::InstanceMethods)
250
252
  end
251
253
 
252
254
  def onix_languages_example(options = {})
253
- opt = {
255
+ attributes = {
254
256
  :languages => [
255
257
  stub('Language', :language_onix_code => 'pol', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_TEXT),
256
258
  stub('Language', :language_onix_code => 'eng', :role_onix_code => Elibri::ONIX::Dict::Release_3_0::LanguageRole::LANGUAGE_OF_ABSTRACTS)
257
259
  ]
258
- }.merge(options)
259
- basic_product.tap do |product|
260
- product.stubs(
261
- opt
262
- )
263
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
260
+ }
261
+ attributes = defaults.merge(attributes).merge(options)
262
+ stub_everything("onix_languages_example", attributes).extend(OnixHelpers::InstanceMethods)
264
263
  end
265
264
 
266
265
 
267
266
  def onix_measurement_example(options = {})
268
- opt = {
267
+ attributes = {
269
268
  :title => "Katowice, mapa",
270
269
  :ean => nil,
271
270
  :isbn_value => '9788324799992',
@@ -278,17 +277,14 @@ module Elibri
278
277
  :map_scale => 50_000,
279
278
  :state => "published",
280
279
  :public? => true
281
- }.merge(options)
282
- mock("product").tap do |product|
283
- product.stubs(
284
- opt
285
- )
286
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
280
+ }
281
+ attributes = defaults.merge(attributes).merge(options)
282
+ stub_everything("onix_measurement_example", attributes).extend(OnixHelpers::InstanceMethods)
287
283
  end
288
284
 
289
285
 
290
286
  def onix_sale_restrictions_example(options = {})
291
- opt = {
287
+ attributes = {
292
288
  :sale_restricted? => true,
293
289
  :sale_restricted_for => 'Empik',
294
290
  :sale_restricted_to => Date.new(2012, 7, 22),
@@ -296,38 +292,26 @@ module Elibri
296
292
  :publication_month => 7,
297
293
  :publication_day => 12
298
294
  }.merge(options)
299
- basic_product.tap do |product|
300
- product.stubs(
301
- opt
302
- )
303
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
295
+ basic_product(attributes)
304
296
  end
305
297
 
306
298
 
307
299
  def onix_audience_range_example(options = {})
308
- opt = {
300
+ attributes = {
309
301
  :audience_age_from => 7,
310
302
  :audience_age_to => 10
311
303
  }.merge(options)
312
- basic_product.tap do |product|
313
- product.stubs(
314
- opt
315
- )
316
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
304
+ basic_product(attributes)
317
305
  end
318
306
 
319
307
 
320
308
  def onix_publisher_info_example(options = {})
321
- opt = {
309
+ attributes = {
322
310
  :publisher_name => 'G+J Gruner+Jahr Polska',
323
311
  :publisher_id => 14,
324
312
  :imprint => stub('Imprint', :name => 'National Geographic')
325
313
  }.merge(options)
326
- basic_product.tap do |product|
327
- product.stubs(
328
- opt
329
- )
330
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
314
+ basic_product(attributes)
331
315
  end
332
316
 
333
317
 
@@ -340,206 +324,154 @@ module Elibri
340
324
  categories << stub('ElibriProductCategory', :id => category1_id, :full_node_path_name => "Kategoria #{category1_id}") if category1_id
341
325
  categories << stub('ElibriProductCategory', :id => category2_id, :full_node_path_name => "Kategoria #{category2_id}") if category2_id
342
326
 
343
- opt = {
327
+ attributes = {
344
328
  :elibri_product_category1_id => category1_id,
345
329
  :elibri_product_category2_id => category2_id,
346
330
  :elibri_product_categories => categories
347
331
  }.merge(options)
348
- basic_product.tap do |product|
349
- product.stubs(
350
- opt
351
- )
352
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
332
+ basic_product(attributes)
353
333
  end
354
334
 
355
335
 
356
336
  def onix_edition_example(options = {})
357
- opt = {
337
+ attributes = {
358
338
  :edition_statement => 'wyd. 3, poprawione'
359
339
  }.merge(options)
360
- basic_product.tap do |product|
361
- product.stubs(
362
- opt
363
- )
364
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
340
+ basic_product(attributes)
365
341
  end
366
342
 
367
343
 
368
344
  def onix_ebook_extent_example(options = {})
369
- opt = {
345
+ attributes = {
370
346
  :example_title => 'E-book (rozmiar pliku, ilość stron i obrazków)',
371
347
  :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::EBOOK,
372
348
  :file_size => 1.22,
373
349
  :number_of_pages => 150,
374
350
  :number_of_illustrations => 12
375
351
  }.merge(options)
376
- basic_product.tap do |product|
377
- product.stubs(
378
- opt
379
- )
380
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
352
+ basic_product(attributes)
381
353
  end
382
354
 
383
355
  def onix_audiobook_extent_example(options = {})
384
- opt = {
385
- :example_title => 'Audio CD z długością ścieżki',
386
- :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::AUDIO_CD,
387
- :duration => 340
388
- }.merge(options)
389
- basic_product.tap do |product|
390
- product.stubs(
391
- opt
392
- )
393
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
356
+ attributes = {
357
+ :example_title => 'Audio CD z długością ścieżki',
358
+ :product_form_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductFormCode::AUDIO_CD,
359
+ :duration => 340
360
+ }.merge(options)
361
+ basic_product(attributes)
394
362
  end
395
363
 
396
364
  def onix_no_contributors_example(options = {})
397
- opt = {
398
- :example_title => 'Brak autorów',
399
- :authorship_kind => ActiveSupport::StringInquirer.new("no_contributor")
400
- }.merge(options)
401
- basic_product.tap do |product|
402
- product.stubs(
403
- opt
404
- )
405
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
365
+ attributes = {
366
+ :example_title => 'Brak autorów',
367
+ :authorship_kind => ActiveSupport::StringInquirer.new("no_contributor")
368
+ }.merge(options)
369
+ basic_product(attributes)
406
370
  end
407
371
 
408
372
  def onix_collective_work_example(options = {})
409
- opt = {
373
+ attributes = {
410
374
  :example_title => 'Praca zbiorowa',
411
375
  :authorship_kind => ActiveSupport::StringInquirer.new("collective")
412
376
  }.merge(options)
413
- basic_product.tap do |product|
414
- product.stubs(
415
- opt
416
- )
417
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
377
+ basic_product(attributes)
418
378
  end
419
379
 
420
380
  def onix_contributors_example(options = {})
421
- opt = {
422
- :example_title => 'Wyszczególnieni autorzy',
423
- :title => "Taka jest nasza wiara",
424
- :authorship_kind => ActiveSupport::StringInquirer.new("user_given"),
425
- :contributors => [
426
- stub('Contributor',
427
- :artificial_id => 255,
428
- :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
429
- :missing_parts => true,
430
- :full_name => 'Św. Tomasz z Akwinu',
431
- :biography => stub('OtherText', :text => 'Tomasz z Akwinu, Akwinata, łac. Thoma de Aquino (ur. 1225, zm. 7 marca 1274) – filozof scholastyczny, teolog, członek zakonu dominikanów. Był jednym z najwybitniejszych myślicieli w dziejach chrześcijaństwa. Święty Kościoła katolickiego, jeden z doktorów Kościoła, który nauczając przekazywał owoce swej kontemplacji (łac. contemplata aliis tradere).'),
432
- :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
433
- ).extend(MockMethodMissing),
434
- stub('Contributor',
435
- :artificial_id => 256,
436
- :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
437
- :language_onix_code => 'lat',
438
- :title => 'prof. ks.',
439
- :name => 'Henryk',
440
- :last_name_prefix => 'von',
441
- :last_name => 'Hausswolff',
442
- :last_name_postfix => 'OP',
443
- :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
444
- ).extend(MockMethodMissing)
445
- ]
446
- }.merge(options)
447
- basic_product.tap do |product|
448
- product.stubs(
449
- opt
450
- )
451
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
381
+ attributes = {
382
+ :example_title => 'Wyszczególnieni autorzy',
383
+ :title => "Taka jest nasza wiara",
384
+ :authorship_kind => ActiveSupport::StringInquirer.new("user_given"),
385
+ :contributors => [
386
+ stub('Contributor',
387
+ :artificial_id => 255,
388
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
389
+ :missing_parts => true,
390
+ :full_name => 'Św. Tomasz z Akwinu',
391
+ :biography => stub('OtherText', :text => 'Tomasz z Akwinu, Akwinata, łac. Thoma de Aquino (ur. 1225, zm. 7 marca 1274) – filozof scholastyczny, teolog, członek zakonu dominikanów. Był jednym z najwybitniejszych myślicieli w dziejach chrześcijaństwa. Święty Kościoła katolickiego, jeden z doktorów Kościoła, który nauczając przekazywał owoce swej kontemplacji (łac. contemplata aliis tradere).'),
392
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
393
+ ).extend(MockMethodMissing),
394
+ stub('Contributor',
395
+ :artificial_id => 256,
396
+ :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::TRANSLATOR,
397
+ :language_onix_code => 'lat',
398
+ :title => 'prof. ks.',
399
+ :name => 'Henryk',
400
+ :last_name_prefix => 'von',
401
+ :last_name => 'Hausswolff',
402
+ :last_name_postfix => 'OP',
403
+ :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
404
+ ).extend(MockMethodMissing)
405
+ ]
406
+ }.merge(options)
407
+ basic_product(attributes)
452
408
  end
453
409
 
454
410
  def onix_announced_product_example(options = {})
455
- opt = {
411
+ attributes = {
456
412
  :state => :announced,
457
413
  :publisher_symbol => "Światu nie mamy czego zazdrościć.",
458
- :or_title => "Nothing to Envy: Ordinary Lives in North Korea",
414
+ :original_title => "Nothing to Envy: Ordinary Lives in North Korea",
459
415
  :collection_part => '33',
460
416
  :title => 'Światu nie mamy czego zazdrościć.',
461
417
  :subtitle => "Zwyczajne losy mieszkańców Korei Północnej.",
462
418
  :publication_year => 2011
463
419
  }.merge(options)
464
- basic_product.tap do |product|
465
- product.stubs(
466
- opt
467
- )
468
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
420
+ basic_product(attributes)
469
421
  end
470
422
 
471
423
  def onix_preorder_product_example(options = {})
472
- opt = {
424
+ attributes = {
473
425
  :state => :preorder,
474
426
  :publication_year => 2011,
475
427
  :publication_month => 2,
476
428
  :publication_day => 10
477
429
  }.merge(options)
478
- basic_product.tap do |product|
479
- product.stubs(
480
- opt
481
- )
482
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
430
+ basic_product(attributes)
483
431
  end
484
432
 
485
433
  def onix_published_product_example(options = {})
486
- opt = {
434
+ attributes = {
487
435
  :state => :published,
488
436
  :publication_year => 2011,
489
437
  :publication_month => 2
490
438
  }.merge(options)
491
- basic_product.tap do |product|
492
- product.stubs(
493
- opt
494
- )
495
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
439
+ basic_product(attributes)
496
440
  end
497
441
 
498
442
  def onix_out_of_print_product_example(options = {})
499
- opt = {
443
+ attributes = {
500
444
  :state => :out_of_print
501
445
  }.merge(options)
502
- basic_product.tap do |product|
503
- product.stubs(
504
- opt
505
- )
506
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
446
+ basic_product(attributes)
507
447
  end
508
448
 
509
449
  def onix_titles_example(options = {})
510
- opt = {
450
+ attributes = {
511
451
  :publisher_symbol => "Światu nie mamy czego zazdrościć.",
512
- :or_title => "Nothing to Envy: Ordinary Lives in North Korea",
452
+ :original_title => "Nothing to Envy: Ordinary Lives in North Korea",
513
453
  :collection_part => '33',
514
454
  :title => 'Światu nie mamy czego zazdrościć.',
515
455
  :subtitle => "Zwyczajne losy mieszkańców Korei Północnej."
516
456
  }.merge(options)
517
- basic_product.tap do |product|
518
- product.stubs(
519
- opt
520
- )
521
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
457
+ basic_product(attributes)
522
458
  end
523
459
 
524
460
  def onix_title_with_collection_example(options = {})
525
- opt = {
461
+ attributes = {
526
462
  :publisher_symbol => "Thorgal 33 Statek-Miecz TWARDA",
527
- :or_title => "Thorgal: Le Bateau-Sabre",
463
+ :original_title => "Thorgal: Le Bateau-Sabre",
528
464
  :collection_part => '33',
529
465
  :title => 'Statek-Miecz',
530
466
  :collection => stub('PublisherCollection', :name => 'Thorgal')
531
467
  }.merge(options)
532
- basic_product.tap do |product|
533
- product.stubs(
534
- opt
535
- )
536
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
468
+ basic_product(attributes)
537
469
  end
538
470
 
539
471
 
540
472
 
541
473
  def onix_texts_example(options = {})
542
- opt = {
474
+ attributes = {
543
475
  :other_texts => [
544
476
  stub('OtherText',
545
477
  :artificial_id => 133,
@@ -571,29 +503,21 @@ module Elibri
571
503
  ).extend(MockMethodMissing),
572
504
  ]
573
505
  }.merge(options)
574
- basic_product.tap do |product|
575
- product.stubs(
576
- opt
577
- )
578
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
506
+ basic_product(attributes)
579
507
  end
580
508
 
581
509
 
582
510
  def onix_related_products_example(options = {})
583
- opt = {
511
+ attributes = {
584
512
  :facsimiles => [stub('Product', :publisher_name => 'PWN', :publisher_id => 12, :publisher_symbol => 'Tytuł dodruku', :isbn_value => '9788324705818', :record_reference => 'abcdefghijk')],
585
513
  :similar_products => [stub('Product', :publisher_name => 'WNT', :publisher_id => 13, :publisher_symbol => 'Tytuł podobnej książki', :isbn_value => '9788324799992', :record_reference => 'kjihgfedcba')]
586
514
  }.merge(options)
587
- basic_product.tap do |product|
588
- product.stubs(
589
- opt
590
- )
591
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
515
+ basic_product(attributes)
592
516
  end
593
517
 
594
518
 
595
519
  def onix_supply_details_example(options = {})
596
- opt = {
520
+ attributes = {
597
521
  :product_availabilities => [
598
522
  stub('ProductAvailability',
599
523
  :supplier_identifier => 'GILD-123',
@@ -626,32 +550,24 @@ module Elibri
626
550
  )
627
551
  ]
628
552
  }.merge(options)
629
- basic_product.tap do |product|
630
- product.stubs(
631
- opt
632
- )
633
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
553
+ basic_product(attributes)
634
554
  end
635
555
 
636
556
 
637
557
  def onix_series_memberships_example(options = {})
638
- opt = {
558
+ attributes = {
639
559
  :series_membership_kind => stub('series_membership_kind', :user_given? => true),
640
560
  :series_memberships => [
641
561
  stub('SeriesMembership', :series_name => 'Lektury szkolne', :number_within_series => '2'),
642
562
  stub('SeriesMembership', :series_name => 'Dla Bystrzaków', :number_within_series => '1')
643
563
  ]
644
564
  }.merge(options)
645
- basic_product.tap do |product|
646
- product.stubs(
647
- opt
648
- )
649
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
565
+ basic_product(attributes)
650
566
  end
651
567
 
652
568
 
653
569
  def onix_supporting_resources_example(options = {})
654
- opt = {
570
+ attributes = {
655
571
  :attachments => [
656
572
  stub('ProductAttachment',
657
573
  :id => 667,
@@ -671,32 +587,24 @@ module Elibri
671
587
  )
672
588
  ]
673
589
  }.merge(options)
674
- basic_product.tap do |product|
675
- product.stubs(
676
- opt
677
- )
678
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
590
+ basic_product(attributes)
679
591
  end
680
592
 
681
593
 
682
594
  def onix_elibri_extensions_example(options = {})
683
- opt = {
595
+ attributes = {
684
596
  :cover_type_id => Elibri::XmlMocks::PAPERBACK,
685
597
  :vat => 5,
686
598
  :pkwiu => "58.11.1",
687
599
  :price_amount => 12.99,
688
600
  :preview_exists? => true
689
601
  }.merge(options)
690
- basic_product.tap do |product|
691
- product.stubs(
692
- opt
693
- )
694
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
602
+ basic_product(attributes)
695
603
  end
696
604
 
697
605
 
698
606
  def contributor_mock(options = {})
699
- opt = {
607
+ attributes = {
700
608
  :artificial_id => 240,
701
609
  :role_onix_code => Elibri::ONIX::Dict::Release_3_0::ContributorRole::AUTHOR,
702
610
  :language_onix_code => 'pol',
@@ -708,15 +616,11 @@ module Elibri
708
616
  :biography => stub('OtherText', :text => 'Biografia Sienkiewicza', :exportable? => true, :is_a_review? => false, :resource_link => 'http://example').extend(MockMethodMissing),
709
617
  :updated_at => Date.new(2011, 11, 04).to_time + 10.hours + 5.minutes + 27.seconds
710
618
  }.merge(options)
711
- mock('Contributor').tap do |contributor|
712
- contributor.stubs(
713
- opt
714
- )
715
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
619
+ stub_everything('Contributor', attributes)
716
620
  end
717
621
 
718
622
  def review_mock(options = {})
719
- opt = {
623
+ attributes = {
720
624
  :artificial_id => 137,
721
625
  :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::REVIEW,
722
626
  :text => 'Recenzja książki',
@@ -726,71 +630,55 @@ module Elibri
726
630
  :is_a_review? => true,
727
631
  :resource_link => 'http://example'
728
632
  }.merge(options)
729
- mock('OtherText').tap do |other_text|
730
- other_text.stubs(
731
- opt
732
- )
733
- end.extend(MockMethodMissing)
633
+ stub_everything('OtherText', attributes)
734
634
  end
735
635
 
736
636
  def supply_detail_mock(options = {})
737
- opt =
738
- {
739
- :supplier_identifier => 'GILD-123',
740
- :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
741
- :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
742
- :supplier => stub('Supplier',
743
- :name => 'Gildia.pl',
744
- :nip => '521-33-59-408',
745
- :phone => '22 631 40 83',
746
- :email => 'bok@gildia.pl',
747
- :website => 'http://gildia.pl'
748
- ),
749
- :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
750
- :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
751
- }.merge(options)
752
- mock('ProductAvailability').tap do |aval|
753
- aval.stubs(
754
- opt
755
- )
756
- end.extend(MockMethodMissing)
637
+ attributes = {
638
+ :supplier_identifier => 'GILD-123',
639
+ :supplier_role_onix_code => Elibri::ONIX::Dict::Release_3_0::SupplierRole::PUB_NON_EXL_DIST,
640
+ :product_availability_onix_code => Elibri::ONIX::Dict::Release_3_0::ProductAvailabilityType::IN_STOCK,
641
+ :supplier => stub('Supplier',
642
+ :name => 'Gildia.pl',
643
+ :nip => '521-33-59-408',
644
+ :phone => '22 631 40 83',
645
+ :email => 'bok@gildia.pl',
646
+ :website => 'http://gildia.pl'
647
+ ),
648
+ :stock_info => stub('stock_info', :exact_info? => true, :on_hand => '1000'),
649
+ :price_infos => [ stub('PriceInfo', :minimum_order_quantity => 20, :amount => 12.99, :vat => 7, :currency_code => 'PLN') ]
650
+ }.merge(options)
651
+ stub_everything('ProductAvailability', attributes)
757
652
  end
758
653
 
759
654
  def imprint_mock(options = {})
760
- opt =
655
+ attributes =
761
656
  {
762
657
  :name => 'National Geographic'
763
658
  }.merge(options)
764
- mock('Imprint').tap do |impr|
765
- impr.stubs(
766
- opt
767
- )
768
- end.extend(MockMethodMissing)
659
+
660
+ stub_everything('Imprint', attributes)
769
661
  end
770
662
 
771
663
  def collection_mock(options = {})
772
- opt =
664
+ attributes =
773
665
  {
774
666
  :name => 'Nazwa kolekcji'
775
667
  }.merge(options)
776
- mock('PublisherCollection').tap do |coll|
777
- coll.stubs(
778
- opt
779
- )
780
- end.extend(MockMethodMissing)
668
+ stub_everything('PublisherCollection', attributes)
781
669
  end
782
670
 
783
671
  def authorship_kind_mock(options = {})
784
- opt = {
672
+ attributes = {
785
673
  :user_given? => true,
786
674
  :collective? => false,
787
675
  :no_contributor? => false
788
676
  }.merge(options)
789
- stub('AuthorshipKind', opt)
677
+ stub('AuthorshipKind', attributes)
790
678
  end
791
679
 
792
680
  def description_mock(options = {})
793
- opt =
681
+ attributes =
794
682
  {
795
683
  :artificial_id => 137,
796
684
  :type_onix_code => Elibri::ONIX::Dict::Release_3_0::OtherTextType::MAIN_DESCRIPTION,
@@ -801,16 +689,11 @@ module Elibri
801
689
  :is_a_review? => false,
802
690
  :resource_link => 'http://example'
803
691
  }.merge(options)
804
- mock('OtherText').tap do |descr|
805
- descr.stubs(
806
- opt
807
- )
808
- end.extend(MockMethodMissing)
692
+ stub_everything('OtherText', attributes)
809
693
  end
810
694
 
811
695
  def product_attachment_mock(options = {})
812
- opt =
813
- {
696
+ attributes = {
814
697
  :id => 668,
815
698
  :attachment_type_code => Elibri::ONIX::Dict::Release_3_0::ResourceContentType::FRONT_COVER,
816
699
  :file_content_type => 'image/png',
@@ -818,22 +701,14 @@ module Elibri
818
701
  :file => paperclip_attachment_mock,
819
702
  :updated_at => Date.new(2011, 12, 01).to_time + 19.hours + 5.minutes + 28.seconds
820
703
  }.merge(options)
821
- mock('ProductAttachment').tap do |att|
822
- att.stubs(
823
- opt
824
- )
825
- end.extend(MockMethodMissing)
704
+ stub_everything('ProductAttachment', attributes)
826
705
  end
827
706
 
828
707
  def paperclip_attachment_mock(options = {})
829
- opt = {
708
+ attributes = {
830
709
  :url => 'http://elibri.com.pl/sciezka/do/pliku.png'
831
710
  }.merge(options)
832
- mock('Paperclip::Attachment').tap do |paperclip|
833
- paperclip.stubs(
834
- opt
835
- )
836
- end.extend(MockMethodMissing)
711
+ stub_everything('Paperclip::Attachment', attributes)
837
712
  end
838
713
 
839
714
  def product_with_similars_mock(options = {})
@@ -1,3 +1,3 @@
1
1
  module ElibriOnixMocks
2
- VERSION = "0.1.6"
3
- end
2
+ VERSION = "0.1.7"
3
+ end
@@ -22,9 +22,10 @@ describe Elibri::XmlMocks::Examples do
22
22
  ].each do |symbol|
23
23
 
24
24
  it "should create #{symbol} xml and parse it properly" do
25
- Elibri::XmlMocks::Examples.send(symbol, {}).should_not be_nil
26
- Elibri::ONIX::XMLGenerator.new(Elibri::XmlMocks::Examples.send(symbol, {})).should_not be_nil
27
- Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(Elibri::XmlMocks::Examples.send(symbol, {})).to_s)
25
+ product_example = Elibri::XmlMocks::Examples.send(symbol, {})
26
+ product_example.should_not be_nil
27
+ Elibri::ONIX::XMLGenerator.new(product_example).should_not be_nil
28
+ Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(product_example).to_s)
28
29
  end
29
30
 
30
31
  end
@@ -41,7 +42,6 @@ describe Elibri::XmlMocks::Examples do
41
42
  product_with_categories = Elibri::XmlMocks::Examples.onix_subjects_example(:elibri_product_category1_id => nil, :elibri_product_category2_id => nil)
42
43
  message = Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(product_with_categories).to_s)
43
44
  message.products.first.subjects.size.should == 0
44
-
45
45
  end
46
46
 
47
47
  NAME_STRING_VECTOR = {
@@ -53,7 +53,7 @@ describe Elibri::XmlMocks::Examples do
53
53
  [:collection, Proc.new { Elibri::XmlMocks::Examples.collection_mock(:name => 'nazwa') } ] => [:collection_title, 'nazwa'],
54
54
  # [ :atrybut do podania do mocka, proc ktory wygeneruje mock ] => [ :atrybut w elibri, wartosc oczekiwana ]
55
55
  :collection_part => :collection_part,
56
- :or_title => :original_title,
56
+ :original_title => :original_title,
57
57
  :trade_title => :trade_title,
58
58
  [ :sale_restricted_to, Proc.new { Date.new(2011, 1, 1) } ] => [ :parsed_publishing_date, [2011, 1, 1] ],
59
59
  :record_reference => :record_reference,
@@ -90,10 +90,10 @@ describe Elibri::XmlMocks::Examples do
90
90
  :duration => :duration,
91
91
  :file_size => :file_size,
92
92
  ### atrybuty powiązane z kind_of_measurable
93
- #:width => :width,
94
- #:weight => :weight,
95
- #:thickness => :thickness,
96
- #:height => :height,
93
+ :width => :width,
94
+ :weight => :weight,
95
+ :thickness => :thickness,
96
+ :height => :height,
97
97
  }
98
98
 
99
99
  NAME_INT_VECTOR.keys.each do |property|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elibri_onix_mocks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Piotr Szmielew
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-18 00:00:00 Z
18
+ date: 2012-06-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -162,6 +162,7 @@ files:
162
162
  - lib/elibri_onix_mocks.rb
163
163
  - lib/elibri_onix_mocks/generators/xml_generator.rb
164
164
  - lib/elibri_onix_mocks/mocks/mock_method_missing.rb
165
+ - lib/elibri_onix_mocks/mocks/product.rb
165
166
  - lib/elibri_onix_mocks/mocks/xml_mocks.rb
166
167
  - lib/elibri_onix_mocks/onix_helpers.rb
167
168
  - lib/elibri_onix_mocks/version.rb
@@ -197,10 +198,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  requirements: []
198
199
 
199
200
  rubyforge_project: elibri_onix_mocks
200
- rubygems_version: 1.8.21
201
+ rubygems_version: 1.8.19
201
202
  signing_key:
202
203
  specification_version: 3
203
204
  summary: Gem that allows you to mock eLibri style xmls
204
- test_files:
205
- - spec/elibri_onix_mocks_spec.rb
206
- - spec/spec_helper.rb
205
+ test_files: []
206
+