onix 0.8.4 → 0.8.5

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.
@@ -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
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Product" do
5
+ describe ONIX::Product do
6
6
 
7
7
  before(:each) do
8
8
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,7 +11,7 @@ context "ONIX::Product" do
11
11
  @product_node = @doc.root
12
12
  end
13
13
 
14
- specify "should provide read access to first level attributes" do
14
+ it "should provide read access to first level attributes" do
15
15
  product = ONIX::Product.from_xml(@product_node.to_s)
16
16
 
17
17
  product.record_reference.should eql("365-9780194351898")
@@ -32,27 +32,27 @@ context "ONIX::Product" do
32
32
  product.dimensions.should eql("100x200")
33
33
  end
34
34
 
35
- specify "should provide read access to product IDs" do
35
+ it "should provide read access to product IDs" do
36
36
  product = ONIX::Product.from_xml(@product_node.to_s)
37
37
  product.product_identifiers.size.should eql(3)
38
38
  end
39
39
 
40
- specify "should provide read access to titles" do
40
+ it "should provide read access to titles" do
41
41
  product = ONIX::Product.from_xml(@product_node.to_s)
42
42
  product.titles.size.should eql(1)
43
43
  end
44
44
 
45
- specify "should provide read access to subjects" do
45
+ it "should provide read access to subjects" do
46
46
  product = ONIX::Product.from_xml(@product_node.to_s)
47
47
  product.subjects.size.should eql(1)
48
48
  end
49
49
 
50
- specify "should provide read access to measurements" do
50
+ it "should provide read access to measurements" do
51
51
  product = ONIX::Product.from_xml(@product_node.to_s)
52
52
  product.measurements.size.should eql(1)
53
53
  end
54
54
 
55
- specify "should provide write access to first level attributes" do
55
+ it "should provide write access to first level attributes" do
56
56
  product = ONIX::Product.new
57
57
 
58
58
  product.notification_type = 3
@@ -83,7 +83,7 @@ context "ONIX::Product" do
83
83
  product.to_xml.to_s.include?("<YearFirstPublished>1998</YearFirstPublished>").should be_true
84
84
  end
85
85
 
86
- specify "should correctly from_xml files that have an invalid publication date" do
86
+ it "should correctly from_xml files that have an invalid publication date" do
87
87
  file = File.join(@data_path, "product_invalid_pubdate.xml")
88
88
  product = ONIX::Product.from_xml(File.read(file))
89
89
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Publisher" do
5
+ describe ONIX::Publisher do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@ context "ONIX::Publisher" 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
  pub = ONIX::Publisher.from_xml(@root.to_s)
16
16
  pub.to_xml.to_s[0,11].should eql("<Publisher>")
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
  pub = ONIX::Publisher.from_xml(@root.to_s)
21
21
  pub.publishing_role.should eql(1)
22
22
  pub.publisher_name.should eql("Desbooks Publishing")
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
  pub = ONIX::Publisher.new
27
27
 
28
28
  pub.publisher_name = "Paulist Press"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Reader" do
5
+ describe ONIX::Reader do
6
6
 
7
7
  before(:each) do
8
8
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -14,30 +14,30 @@ context "ONIX::Reader" do
14
14
  @iso_8859_1_file = File.join(@data_path, "iso_8859_1.xml")
15
15
  end
16
16
 
17
- specify "should initialize with a filename" do
17
+ it "should initialize with a filename" do
18
18
  reader = ONIX::Reader.new(@file1)
19
19
  reader.instance_variable_get("@reader").should be_a_kind_of(Nokogiri::XML::Reader)
20
20
  end
21
21
 
22
- specify "should initialize with an IO object" do
22
+ it "should initialize with an IO object" do
23
23
  File.open(@file1,"rb") do |f|
24
24
  reader = ONIX::Reader.new(f)
25
25
  reader.instance_variable_get("@reader").should be_a_kind_of(Nokogiri::XML::Reader)
26
26
  end
27
27
  end
28
28
 
29
- specify "should provide access to various XML metadata from file" do
29
+ it "should provide access to various XML metadata from file" do
30
30
  filename = File.join(@data_path, "reference_with_release_attrib.xml")
31
31
  reader = ONIX::Reader.new(filename)
32
32
  reader.release.should eql(BigDecimal.new("2.1"))
33
33
  end
34
34
 
35
- specify "should provide access to the header in an ONIX file" do
35
+ it "should provide access to the header in an ONIX file" do
36
36
  reader = ONIX::Reader.new(@file1)
37
37
  reader.header.should be_a_kind_of(ONIX::Header)
38
38
  end
39
39
 
40
- specify "should iterate over all product records in an ONIX file" do
40
+ it "should iterate over all product records in an ONIX file" do
41
41
  reader = ONIX::Reader.new(@file1)
42
42
  counter = 0
43
43
  reader.each do |product|
@@ -48,7 +48,7 @@ context "ONIX::Reader" do
48
48
  counter.should eql(1)
49
49
  end
50
50
 
51
- specify "should iterate over all product records in an ONIX file" do
51
+ it "should iterate over all product records in an ONIX file" do
52
52
  reader = ONIX::Reader.new(@file2)
53
53
  products = []
54
54
  reader.each do |product|
@@ -63,7 +63,7 @@ context "ONIX::Reader" do
63
63
  # libxml can handle the 3 standard entities fine (&amp; &lt; and ^gt;) but
64
64
  # barfs when it encounters others. In theory other entities are defined in the
65
65
  # ONIX DTD, but I can't work out how to get libxml to recognise them
66
- specify "should correctly parse a file that has an entity in it" do
66
+ it "should correctly parse a file that has an entity in it" do
67
67
  reader = ONIX::Reader.new(@entity_file)
68
68
 
69
69
  products = []
@@ -78,7 +78,7 @@ context "ONIX::Reader" do
78
78
  end
79
79
 
80
80
  # for some reason I'm getting segfaults when I read a file with more than 7 records
81
- specify "should correctly parse a file with more than 7 records in in" do
81
+ it "should correctly parse a file with more than 7 records in in" do
82
82
  reader = ONIX::Reader.new(@long_file)
83
83
  counter = 0
84
84
  reader.each do |product|
@@ -88,7 +88,7 @@ context "ONIX::Reader" do
88
88
  counter.should eql(346)
89
89
  end
90
90
 
91
- specify "should transparently convert a iso-8859-1 file to utf-8" do
91
+ it "should transparently convert a iso-8859-1 file to utf-8" do
92
92
  reader = ONIX::Reader.new(@iso_8859_1_file)
93
93
  product = nil
94
94
  reader.each do |p|
@@ -105,7 +105,7 @@ context "ONIX::Reader" do
105
105
 
106
106
  end
107
107
 
108
- specify "should transparently convert a utf-16 file to utf-8" do
108
+ it "should transparently convert a utf-16 file to utf-8" do
109
109
  reader = ONIX::Reader.new(@utf_16_file)
110
110
  product = nil
111
111
  reader.each do |p|
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::SalesRestriction" do
5
+ describe "ONIX::SalesRestriction" do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@ context "ONIX::SalesRestriction" 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
  sr = ONIX::SalesRestriction.from_xml(@root.to_s)
16
16
  sr.to_xml.to_s[0,18].should eql("<SalesRestriction>")
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
  sr = ONIX::SalesRestriction.from_xml(@root.to_s)
21
21
 
22
22
  sr.sales_restriction_type.should eql(0)
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
  sr = ONIX::SalesRestriction.new
27
27
 
28
28
  sr.sales_restriction_type = 1
@@ -30,4 +30,3 @@ context "ONIX::SalesRestriction" do
30
30
  end
31
31
 
32
32
  end
33
-
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::SenderIdentifier" do
5
+ describe ONIX::SenderIdentifier do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::SenderIdentifier" 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::SenderIdentifier.from_xml(@root.to_s)
16
16
  id.to_xml.to_s[0,18].should eql("<SenderIdentifier>")
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::SenderIdentifier.from_xml(@root.to_s)
21
21
 
22
22
  id.sender_id_type.should eql(1)
23
23
  id.id_value.should eql("123456")
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::SenderIdentifier.new
28
28
 
29
29
  id.sender_id_type = 1
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::SeriesIdentifier" do
5
+ describe ONIX::SeriesIdentifier do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::SeriesIdentifier" 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
  series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
16
16
  series.to_xml.to_s[0,18].should eql("<SeriesIdentifier>")
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
  series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
21
21
 
22
22
  series.series_id_type.should eql(1)
23
23
  series.id_value.should eql("10001")
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
  series = ONIX::SeriesIdentifier.new
28
28
 
29
29
  series.series_id_type = 9
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Series" do
5
+ describe ONIX::Series do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@ context "ONIX::Series" 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
  series = ONIX::Series.from_xml(@root.to_s)
16
16
  series.to_xml.to_s[0,8].should eql("<Series>")
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
  series = ONIX::Series.from_xml(@root.to_s)
21
21
 
22
22
  series.title_of_series.should eql("Citizens and Their Governments")
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
  series = ONIX::Series.new
27
27
 
28
28
  series.title_of_series = "Cool Science Careers"
@@ -1,7 +1,10 @@
1
1
  # coding: utf-8
2
2
 
3
+ require "rubygems"
4
+ require "bundler"
5
+ Bundler.setup
6
+
3
7
  require 'date'
4
8
  require 'stringio'
5
9
  require 'rubygems'
6
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
7
10
  require 'onix'
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Stock" do
5
+ describe ONIX::Stock do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Stock" 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
  s = ONIX::Stock.from_xml(@root.to_s)
16
16
  s.to_xml.to_s[0,7].should eql("<Stock>")
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
  s = ONIX::Stock.from_xml(@root.to_s)
21
21
 
22
22
  # note that these fields *should* be numeric according to the ONIX spec,
@@ -25,7 +25,7 @@ context "ONIX::Stock" do
25
25
  s.on_order.should eql("0")
26
26
  end
27
27
 
28
- specify "should provide write access to first level attributes" do
28
+ it "should provide write access to first level attributes" do
29
29
  s = ONIX::Stock.new
30
30
 
31
31
  s.on_hand = "123"