elibri_onix_mocks 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -248,23 +248,6 @@ module Elibri
248
248
  end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
249
249
  end
250
250
 
251
-
252
- def onix_categories_example(options = {})
253
- opt = {
254
- :publisher_name => "Buchmann",
255
- :publisher_id => 15,
256
- :publisher_product_categories => [
257
- stub('PublisherProductCategory', :name => "Beletrystyka: Horror"),
258
- stub('PublisherProductCategory', :name => "Beletrystyka: Sensacja")
259
- ]
260
- }.merge(options)
261
- basic_product.tap do |product|
262
- product.stubs(
263
- opt
264
- )
265
- end.extend(OnixHelpers::InstanceMethods).extend(MockMethodMissing)
266
- end
267
-
268
251
  def onix_languages_example(options = {})
269
252
  opt = {
270
253
  :languages => [
@@ -348,10 +331,18 @@ module Elibri
348
331
 
349
332
 
350
333
 
351
- def onix_subjects_example(options = {})
334
+ def onix_subjects_example(options={})
335
+ category1_id = options.has_key?(:elibri_product_category1_id) ? options[:elibri_product_category1_id] : 491
336
+ category2_id = options.has_key?(:elibri_product_category2_id) ? options[:elibri_product_category2_id] : 1110
337
+
338
+ categories = []
339
+ categories << stub('ElibriProductCategory', :id => category1_id, :full_node_path_name => "Kategoria #{category1_id}") if category1_id
340
+ categories << stub('ElibriProductCategory', :id => category2_id, :full_node_path_name => "Kategoria #{category2_id}") if category2_id
341
+
352
342
  opt = {
353
- :elibri_product_category1_id => 1110,
354
- :elibri_product_category2_id => 491
343
+ :elibri_product_category1_id => category1_id,
344
+ :elibri_product_category2_id => category2_id,
345
+ :elibri_product_categories => categories
355
346
  }.merge(options)
356
347
  basic_product.tap do |product|
357
348
  product.stubs(
@@ -798,4 +789,4 @@ module Elibri
798
789
 
799
790
  end
800
791
  end
801
- end
792
+ end
@@ -1,3 +1,3 @@
1
1
  module ElibriOnixMocks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,14 +1,13 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'spec_helper'
4
-
5
4
  $VERBOSE = nil #temp: supress id warnings
6
5
 
7
6
  describe Elibri::XmlMocks::Examples do
8
7
 
9
8
  [
10
9
  :basic_product, :book_example, :onix_record_identifiers_example, :onix_product_form_example,
11
- :onix_epub_details_example, :onix_categories_example, :onix_languages_example,
10
+ :onix_epub_details_example, :onix_languages_example,
12
11
  :onix_measurement_example, :onix_sale_restrictions_example, :onix_audience_range_example,
13
12
  :onix_publisher_info_example, :onix_subjects_example, :onix_edition_example, :onix_ebook_extent_example,
14
13
  :onix_audiobook_extent_example, :onix_no_contributors_example, :onix_collective_work_example,
@@ -28,6 +27,20 @@ describe Elibri::XmlMocks::Examples do
28
27
 
29
28
  end
30
29
 
30
+ it "onix_subjects_example should return a valid list of product categories" do
31
+ product_with_categories = Elibri::XmlMocks::Examples.onix_subjects_example()
32
+ message = Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(product_with_categories).to_s)
33
+ message.products.first.subjects.size.should == 2
34
+
35
+ product_with_categories = Elibri::XmlMocks::Examples.onix_subjects_example(:elibri_product_category1_id => 1110, :elibri_product_category2_id => nil)
36
+ message = Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(product_with_categories).to_s)
37
+ message.products.first.subjects.size.should == 1
38
+
39
+ product_with_categories = Elibri::XmlMocks::Examples.onix_subjects_example(:elibri_product_category1_id => nil, :elibri_product_category2_id => nil)
40
+ message = Elibri::ONIX::Release_3_0::ONIXMessage.from_xml(Elibri::ONIX::XMLGenerator.new(product_with_categories).to_s)
41
+ message.products.first.subjects.size.should == 0
42
+
43
+ end
31
44
  #more tests to add
32
45
 
33
- end
46
+ end
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: 27
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Piotr Szmielew
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-05 00:00:00 Z
18
+ date: 2012-05-08 00:00:00 +02:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rspec
@@ -141,6 +142,7 @@ files:
141
142
  - lib/elibri_onix_mocks/xml_variant.rb
142
143
  - spec/elibri_onix_mocks_spec.rb
143
144
  - spec/spec_helper.rb
145
+ has_rdoc: true
144
146
  homepage: ""
145
147
  licenses: []
146
148
 
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  requirements: []
171
173
 
172
174
  rubyforge_project: elibri_onix_mocks
173
- rubygems_version: 1.8.17
175
+ rubygems_version: 1.5.2
174
176
  signing_key:
175
177
  specification_version: 3
176
178
  summary: Gem that allows you to mock eLibri style xmls