milkfarm-onix 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/CHANGELOG +21 -0
  2. data/README.markdown +1 -0
  3. data/lib/onix.rb +4 -17
  4. data/lib/onix/code_list_extractor.rb +69 -0
  5. data/lib/onix/lists.rb +134 -0
  6. data/lib/onix/product.rb +14 -0
  7. data/lib/onix/sl_product.rb +24 -1
  8. data/lib/onix/version.rb +3 -0
  9. data/lib/onix/work_identifier.rb +28 -0
  10. data/spec/apa_product_spec.rb +9 -9
  11. data/spec/audience_range_spec.rb +4 -4
  12. data/spec/contributor_spec.rb +4 -4
  13. data/spec/header_spec.rb +7 -7
  14. data/spec/imprint_spec.rb +4 -4
  15. data/spec/language_spec.rb +4 -4
  16. data/spec/lists_spec.rb +33 -0
  17. data/spec/market_representation_spec.rb +4 -6
  18. data/spec/measure_spec.rb +4 -4
  19. data/spec/media_file_spec.rb +4 -4
  20. data/spec/normaliser_spec.rb +28 -4
  21. data/spec/other_text_spec.rb +4 -4
  22. data/spec/price_spec.rb +4 -4
  23. data/spec/product_identifier_spec.rb +4 -4
  24. data/spec/product_spec.rb +8 -8
  25. data/spec/publisher_spec.rb +4 -4
  26. data/spec/reader_spec.rb +11 -11
  27. data/spec/sales_restriction_spec.rb +4 -5
  28. data/spec/sender_identifier.rb +4 -4
  29. data/spec/series_identifier_spec.rb +4 -4
  30. data/spec/series_spec.rb +4 -4
  31. data/spec/spec_helper.rb +4 -1
  32. data/spec/stock_spec.rb +4 -4
  33. data/spec/subject_spec.rb +4 -5
  34. data/spec/supply_detail_spec.rb +4 -4
  35. data/spec/title_spec.rb +4 -4
  36. data/spec/website_spec.rb +4 -4
  37. data/spec/work_identifier_spec.rb +39 -0
  38. data/spec/writer_spec.rb +7 -7
  39. data/support/codes/001.tsv +10 -0
  40. data/support/codes/002.tsv +5 -0
  41. data/support/codes/003.tsv +7 -0
  42. data/support/codes/005.tsv +13 -0
  43. data/support/codes/006.tsv +76 -0
  44. data/support/codes/007.tsv +123 -0
  45. data/support/codes/008.tsv +7 -0
  46. data/support/codes/009.tsv +7 -0
  47. data/support/codes/010.tsv +34 -0
  48. data/support/codes/011.tsv +11 -0
  49. data/support/codes/012.tsv +11 -0
  50. data/support/codes/013.tsv +7 -0
  51. data/support/codes/014.tsv +4 -0
  52. data/support/codes/015.tsv +13 -0
  53. data/support/codes/016.tsv +6 -0
  54. data/support/codes/017.tsv +90 -0
  55. data/support/codes/018.tsv +3 -0
  56. data/support/codes/019.tsv +7 -0
  57. data/support/codes/020.tsv +0 -0
  58. data/support/codes/021.tsv +31 -0
  59. data/support/codes/022.tsv +9 -0
  60. data/support/codes/023.tsv +9 -0
  61. data/support/codes/024.tsv +11 -0
  62. data/support/codes/025.tsv +29 -0
  63. data/support/codes/026.tsv +75 -0
  64. data/support/codes/027.tsv +75 -0
  65. data/support/codes/028.tsv +8 -0
  66. data/support/codes/029.tsv +16 -0
  67. data/support/codes/030.tsv +15 -0
  68. data/support/codes/031.tsv +3 -0
  69. data/support/codes/032.tsv +2 -0
  70. data/support/codes/033.tsv +36 -0
  71. data/support/codes/034.tsv +14 -0
  72. data/support/codes/035.tsv +6 -0
  73. data/support/codes/036.tsv +3 -0
  74. data/support/codes/037.tsv +6 -0
  75. data/support/codes/038.tsv +36 -0
  76. data/support/codes/039.tsv +8 -0
  77. data/support/codes/040.tsv +6 -0
  78. data/support/codes/041.tsv +6 -0
  79. data/support/codes/042.tsv +16 -0
  80. data/support/codes/043.tsv +4 -0
  81. data/support/codes/044.tsv +13 -0
  82. data/support/codes/045.tsv +12 -0
  83. data/support/codes/046.tsv +3 -0
  84. data/support/codes/047.tsv +4 -0
  85. data/support/codes/048.tsv +11 -0
  86. data/support/codes/049.tsv +84 -0
  87. data/support/codes/050.tsv +8 -0
  88. data/support/codes/051.tsv +27 -0
  89. data/support/codes/052.tsv +1 -0
  90. data/support/codes/053.tsv +3 -0
  91. data/support/codes/054.tsv +23 -0
  92. data/support/codes/055.tsv +13 -0
  93. data/support/codes/056.tsv +2 -0
  94. data/support/codes/057.tsv +5 -0
  95. data/support/codes/058.tsv +21 -0
  96. data/support/codes/059.tsv +4 -0
  97. data/support/codes/060.tsv +2 -0
  98. data/support/codes/061.tsv +3 -0
  99. data/support/codes/062.tsv +5 -0
  100. data/support/codes/063.tsv +0 -0
  101. data/support/codes/064.tsv +13 -0
  102. data/support/codes/065.tsv +25 -0
  103. data/support/codes/066.tsv +4 -0
  104. data/support/codes/067.tsv +2 -0
  105. data/support/codes/068.tsv +15 -0
  106. data/support/codes/069.tsv +4 -0
  107. data/support/codes/070.tsv +2 -0
  108. data/support/codes/071.tsv +9 -0
  109. data/support/codes/072.tsv +7 -0
  110. data/support/codes/073.tsv +36 -0
  111. data/support/codes/074.tsv +489 -0
  112. data/support/codes/075.tsv +2 -0
  113. data/support/codes/076.tsv +12 -0
  114. data/support/codes/077.tsv +19 -0
  115. data/support/codes/078.tsv +148 -0
  116. data/support/codes/079.tsv +17 -0
  117. data/support/codes/080.tsv +19 -0
  118. data/support/codes/081.tsv +11 -0
  119. data/support/codes/082.tsv +17 -0
  120. data/support/codes/083.tsv +68 -0
  121. data/support/codes/084.tsv +10 -0
  122. data/support/codes/085.tsv +23 -0
  123. data/support/codes/086.tsv +5 -0
  124. data/support/codes/087.tsv +6 -0
  125. data/support/codes/088.tsv +0 -0
  126. data/support/codes/089.tsv +1 -0
  127. data/support/codes/090.tsv +11 -0
  128. data/support/codes/091.tsv +248 -0
  129. data/support/codes/092.tsv +7 -0
  130. data/support/codes/093.tsv +13 -0
  131. data/support/codes/094.tsv +3 -0
  132. data/support/codes/095.tsv +3 -0
  133. data/support/codes/096.tsv +185 -0
  134. data/support/codes/097.tsv +1 -0
  135. data/support/codes/098.tsv +21 -0
  136. data/support/codes/099.tsv +24 -0
  137. data/support/codes/100.tsv +4 -0
  138. data/support/codes/101.tsv +2 -0
  139. data/support/codes/102.tsv +3 -0
  140. data/support/codes/121.tsv +127 -0
  141. data/support/codes/138.tsv +6 -0
  142. data/support/codes/139.tsv +70 -0
  143. data/support/codes/140.tsv +7 -0
  144. data/support/codes/141.tsv +10 -0
  145. data/support/codes/142.tsv +12 -0
  146. data/support/codes/143.tsv +7 -0
  147. data/support/codes/144.tsv +4 -0
  148. data/support/codes/145.tsv +5 -0
  149. data/support/codes/146.tsv +3 -0
  150. data/support/codes/147.tsv +7 -0
  151. data/support/codes/148.tsv +3 -0
  152. data/support/codes/149.tsv +4 -0
  153. data/support/codes/150.tsv +124 -0
  154. data/support/codes/151.tsv +7 -0
  155. data/support/codes/152.tsv +2 -0
  156. data/support/codes/153.tsv +14 -0
  157. data/support/codes/154.tsv +9 -0
  158. data/support/codes/155.tsv +5 -0
  159. data/support/codes/156.tsv +4 -0
  160. data/support/codes/157.tsv +4 -0
  161. data/support/codes/158.tsv +24 -0
  162. data/support/codes/159.tsv +6 -0
  163. data/support/codes/160.tsv +0 -0
  164. data/support/codes/161.tsv +3 -0
  165. data/support/codes/162.tsv +3 -0
  166. data/support/codes/163.tsv +7 -0
  167. data/support/codes/164.tsv +2 -0
  168. data/support/codes/165.tsv +2 -0
  169. data/support/codes/166.tsv +2 -0
  170. data/support/codes/167.tsv +3 -0
  171. data/support/codes/168.tsv +2 -0
  172. data/support/codes/169.tsv +3 -0
  173. data/support/codes/170.tsv +0 -0
  174. data/support/codes/171.tsv +2 -0
  175. data/support/codes/172.tsv +1 -0
  176. data/support/codes/173.tsv +2 -0
  177. data/support/codes/174.tsv +2 -0
  178. data/support/codes/175.tsv +175 -0
  179. data/support/codes/176.tsv +12 -0
  180. data/support/codes/177.tsv +2 -0
  181. data/support/codes/178.tsv +17 -0
  182. data/support/switch-onix-2.1-short-to-reference.xsl +3 -2
  183. metadata +226 -38
  184. data/lib/onix/lists/audience_code.rb +0 -17
  185. data/lib/onix/lists/contributor_role.rb +0 -99
  186. data/lib/onix/lists/country_code.rb +0 -257
  187. data/lib/onix/lists/language_code.rb +0 -498
  188. data/lib/onix/lists/language_role.rb +0 -18
  189. data/lib/onix/lists/notification_type.rb +0 -19
  190. data/lib/onix/lists/product_availability.rb +0 -32
  191. data/lib/onix/lists/product_form.rb +0 -99
  192. data/lib/onix/lists/product_form_detail.rb +0 -157
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::AudienceRange" do
5
+ describe ONIX::AudienceRange do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::AudienceRange" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  aud = ONIX::AudienceRange.from_xml(@root.to_s)
16
16
  aud.to_xml.to_s[0,15].should eql("<AudienceRange>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  aud = ONIX::AudienceRange.from_xml(@root.to_s)
21
21
 
22
22
  aud.audience_range_qualifier.should eql(11)
@@ -28,7 +28,7 @@ context "ONIX::AudienceRange" do
28
28
  aud.audience_range_values[1].should eql(5)
29
29
  end
30
30
 
31
- specify "should provide write access to first level attributes" do
31
+ it "should provide write access to first level attributes" do
32
32
  aud = ONIX::AudienceRange.new
33
33
 
34
34
  aud.audience_range_qualifier = 12
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Contributor" do
5
+ describe ONIX::Contributor do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Contributor" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  header = ONIX::Contributor.from_xml(@root.to_s)
16
16
  header.to_xml.to_s[0,13].should eql("<Contributor>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  contrib = ONIX::Contributor.from_xml(@root.to_s)
21
21
 
22
22
  contrib.contributor_role.should eql("A01")
@@ -24,7 +24,7 @@ context "ONIX::Contributor" do
24
24
  contrib.sequence_number.should eql(1)
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  contrib = ONIX::Contributor.new
29
29
 
30
30
  contrib.contributor_role = "A02"
data/spec/header_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Header" do
5
+ describe ONIX::Header do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Header" do
11
11
  @header_node = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  header = ONIX::Header.from_xml(@header_node.to_s)
16
16
  header.to_xml.to_s[0,8].should eql("<Header>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  header = ONIX::Header.from_xml(@header_node.to_s)
21
21
 
22
22
  header.from_ean_number.should eql("1111111111111")
@@ -42,7 +42,7 @@ context "ONIX::Header" do
42
42
  header.default_class_of_trade.should eql("f")
43
43
  end
44
44
 
45
- specify "should provide write access to first level attributes" do
45
+ it "should provide write access to first level attributes" do
46
46
  header = ONIX::Header.new
47
47
 
48
48
  header.from_ean_number = "1111111111111"
@@ -95,7 +95,7 @@ context "ONIX::Header" do
95
95
  header.to_xml.to_s.include?("<DefaultClassOfTrade>f</DefaultClassOfTrade>").should be_true
96
96
  end
97
97
 
98
- specify "should correctly handle text with & < and >" do
98
+ it "should correctly handle text with & < and >" do
99
99
  header = ONIX::Header.new
100
100
 
101
101
  header.from_company = "James & Healy"
@@ -109,9 +109,9 @@ context "ONIX::Header" do
109
109
  end
110
110
  end
111
111
 
112
- context "ONIX::Header" do
112
+ describe ONIX::Header do
113
113
 
114
- specify "should correctly handle headers with an invalid sent date" do
114
+ it "should correctly handle headers with an invalid sent date" do
115
115
  data_path = File.join(File.dirname(__FILE__),"..","data")
116
116
  file = File.join(data_path, "header_invalid_sentdate.xml")
117
117
  header = ONIX::Header.from_xml(File.read(file))
data/spec/imprint_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Imprint" do
5
+ describe ONIX::Imprint do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@ context "ONIX::Imprint" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  imp = ONIX::Imprint.from_xml(@root.to_s)
16
16
  imp.to_xml.to_s[0,9].should eql("<Imprint>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  imp = ONIX::Imprint.from_xml(@root.to_s)
21
21
 
22
22
  imp.imprint_name.should eql("Oxford University Press UK")
23
23
  end
24
24
 
25
- specify "should provide write access to first level attributes" do
25
+ it "should provide write access to first level attributes" do
26
26
  imp = ONIX::Imprint.new
27
27
 
28
28
  imp.imprint_name = "Paulist Press"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Language" do
5
+ describe ONIX::Language do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Language" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  lan = ONIX::Language.from_xml(@root.to_s)
16
16
  lan.to_xml.to_s[0,10].should eql("<Language>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  lan = ONIX::Language.from_xml(@root.to_s)
21
21
 
22
22
  lan.language_role.should eql(1)
@@ -24,7 +24,7 @@ context "ONIX::Language" do
24
24
  lan.country_code.should eql("US")
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  lan = ONIX::Language.new
29
29
 
30
30
  lan.language_role = 2
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper.rb'
4
+
5
+ describe ONIX::Lists, "list method" do
6
+
7
+ it "should return a hash containing the ProductForm code list" do
8
+ forms = ONIX::Lists.list(7)
9
+ forms.should be_a(Hash)
10
+ forms["BB"].should eql("Hardback")
11
+ end
12
+
13
+ end
14
+
15
+ describe ONIX::Lists, "product_form shortcut method" do
16
+
17
+ it "should return a hash containing the ProductForm code list" do
18
+ forms = ONIX::Lists.product_form
19
+ forms.should be_a(Hash)
20
+ forms["BB"].should eql("Hardback")
21
+ end
22
+
23
+ end
24
+
25
+ describe ONIX::Lists, "PRODUCT_FORM shortcut constant" do
26
+
27
+ it "should return a hash containing the ProductForm code list" do
28
+ forms = ONIX::Lists::PRODUCT_FORM
29
+ forms.should be_a(Hash)
30
+ forms["BB"].should eql("Hardback")
31
+ end
32
+
33
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::MarketRepresentation" do
5
+ describe ONIX::MarketRepresentation do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::MarketRepresentation" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  rep = ONIX::MarketRepresentation.from_xml(@root.to_s)
16
16
  rep.to_xml.to_s[0,22].should eql("<MarketRepresentation>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  rep = ONIX::MarketRepresentation.from_xml(@root.to_s)
21
21
 
22
22
  rep.agent_name.should eql("Allen & Unwin")
23
23
  rep.agent_role.should eql(7)
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  rep = ONIX::MarketRepresentation.new
28
28
 
29
29
  rep.agent_name = "Rainbow Book Agencies"
@@ -35,5 +35,3 @@ context "ONIX::MarketRepresentation" do
35
35
  end
36
36
 
37
37
  end
38
-
39
-
data/spec/measure_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Measure" do
5
+ describe ONIX::Measure do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Measure" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  m = ONIX::Measure.from_xml(@root.to_s)
16
16
  m.to_xml.to_s[0,9].should eql("<Measure>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  m = ONIX::Measure.from_xml(@root.to_s)
21
21
 
22
22
  m.measure_type_code.should eql(1)
@@ -24,7 +24,7 @@ context "ONIX::Measure" do
24
24
  m.measure_unit_code.should eql("mm")
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  m = ONIX::Measure.new
29
29
 
30
30
  m.measure_type_code = 1
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::MediaFile" do
5
+ describe ONIX::MediaFile do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::MediaFile" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  mf = ONIX::MediaFile.from_xml(@root.to_s)
16
16
  mf.to_xml.to_s[0,11].should eql("<MediaFile>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  mf = ONIX::MediaFile.from_xml(@root.to_s)
21
21
  mf.media_file_type_code.should eql(4)
22
22
  mf.media_file_link_type_code.should eql(1)
23
23
  mf.media_file_link.should eql("http://www.allenandunwin.com/BookCovers/resized_9788888028729_224_297_FitSquare.jpg")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  mf = ONIX::MediaFile.new
28
28
 
29
29
  mf.media_file_type_code = 2
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Normaliser", "with a simple short tag file" do
5
+ describe ONIX::Normaliser, "with a simple short tag file" do
6
6
 
7
7
  before(:each) do
8
8
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -14,7 +14,7 @@ context "ONIX::Normaliser", "with a simple short tag file" do
14
14
  File.unlink(@outfile) if File.file?(@outfile)
15
15
  end
16
16
 
17
- specify "should correctly convert short tag file to reference tag" do
17
+ it "should correctly convert short tag file to reference tag" do
18
18
  ONIX::Normaliser.process(@filename, @outfile)
19
19
 
20
20
  File.file?(@outfile).should be_true
@@ -25,7 +25,31 @@ context "ONIX::Normaliser", "with a simple short tag file" do
25
25
 
26
26
  end
27
27
 
28
- context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do
28
+ describe ONIX::Normaliser, "with a short tag file that include HTML tags" do
29
+
30
+ before(:each) do
31
+ @data_path = File.join(File.dirname(__FILE__),"..","data")
32
+ @filename = File.join(@data_path, "short_tags_ivp.xml")
33
+ @outfile = @filename + ".new"
34
+ end
35
+
36
+ after(:each) do
37
+ File.unlink(@outfile) if File.file?(@outfile)
38
+ end
39
+
40
+ it "should correctly convert short tag file to reference tag" do
41
+ ONIX::Normaliser.process(@filename, @outfile)
42
+
43
+ File.file?(@outfile).should be_true
44
+ content = File.read(@outfile)
45
+ content.include?("<m174>").should be_false
46
+ content.include?("<FromCompany>").should be_true
47
+ content.include?("<em>Discipleship Essentials</em>").should be_true
48
+ end
49
+
50
+ end
51
+
52
+ describe ONIX::Normaliser, "with a utf8 file that has illegal control chars" do
29
53
 
30
54
  before(:each) do
31
55
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -37,7 +61,7 @@ context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do
37
61
  File.unlink(@outfile) if File.file?(@outfile)
38
62
  end
39
63
 
40
- specify "should remove all control chars except LF, CR and TAB" do
64
+ it "should remove all control chars except LF, CR and TAB" do
41
65
  ONIX::Normaliser.process(@filename, @outfile)
42
66
 
43
67
  File.file?(@outfile).should be_true
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::OtherText" do
5
+ describe ONIX::OtherText do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::OtherText" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  ot = ONIX::OtherText.from_xml(@root.to_s)
16
16
  ot.to_xml.to_s[0,11].should eql("<OtherText>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  ot = ONIX::OtherText.from_xml(@root.to_s)
21
21
 
22
22
  ot.text_type_code.should eql(2)
23
23
  ot.text[0,7].should eql("A woman")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  ot = ONIX::OtherText.new
28
28
 
29
29
  ot.text_type_code = 2
data/spec/price_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Price" do
5
+ describe ONIX::Price do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::Price" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  p = ONIX::Price.from_xml(@root.to_s)
16
16
  p.to_xml.to_s[0,7].should eql("<Price>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  p = ONIX::Price.from_xml(@root.to_s)
21
21
 
22
22
  p.price_type_code.should eql(2)
23
23
  p.price_amount.should eql(BigDecimal.new("7.5"))
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  p = ONIX::Price.new
28
28
 
29
29
  p.price_type_code = 1
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::ProductIdentifier" do
5
+ describe ONIX::ProductIdentifier do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::ProductIdentifier" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  id = ONIX::ProductIdentifier.from_xml(@root.to_s)
16
16
  id.to_xml.to_s[0,19].should eql("<ProductIdentifier>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  id = ONIX::ProductIdentifier.from_xml(@root.to_s)
21
21
 
22
22
  id.product_id_type.should eql(2)
23
23
  id.id_value.should eql("0858198363")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  id = ONIX::ProductIdentifier.new
28
28
 
29
29
  id.product_id_type = 2