assembly-objectfile 1.6.7 → 1.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 520808c5ac39b61afd39c83367dca268cb07b306
4
- data.tar.gz: 111bf40dec65a8bce22e9620d37dfa3154aa8c7a
3
+ metadata.gz: f6dc0ea8319dd859ec9be81fd8f1f198c7cf4f9b
4
+ data.tar.gz: 658c0a71e1d654e25ef96ed3d6f726ffc62fc032
5
5
  SHA512:
6
- metadata.gz: 4037d0b4500f566e31d552367d7ff60dbd55f9d800e90455c152e59f12e1f3d922bb4f69befd4486d25a6262baae18fba6fbcdde024eb818088583c17400e9bc
7
- data.tar.gz: 7c8d22cee770b2a245dcadf0e63ce31282e1835c1258e3c74fbdbdb72adfaaf49b7a9b488fec1b761f30710eb5d83660fbcd274c1cacc092a3c159307dcd4ce1
6
+ metadata.gz: a651a9d5ef31b219cc861189da4dccacb7d65072718fff634b27adc91e9f6475dc7d3f093f0624ab09e8f90ddb4253adaa52366eb81451fdc341a387a9551731
7
+ data.tar.gz: f6daca5780f916a41a5d4b3f2890ba2432803bb852a0e24837041f5ce489dd06ebebde38caae6d636402653f0b67815f6820971fa35b5d51b4edb53a50e565dc
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  notifications:
2
2
  email: false
3
-
3
+ addons:
4
+ apt:
5
+ packages:
6
+ - libimage-exiftool-perl
4
7
  rvm:
5
- - 1.9.3
6
- - 2.0.0
8
+ - 2.2.5
9
+ - 2.3.1
@@ -16,18 +16,17 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- spec/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.bindir = 'exe'
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  s.require_paths = ['lib']
21
22
 
22
23
  s.add_dependency 'mini_exiftool'
23
24
  s.add_dependency 'mime-types'
24
25
  s.add_dependency 'nokogiri'
25
- # s.add_dependency 'activesupport'
26
26
 
27
27
  s.add_development_dependency 'rake'
28
28
  s.add_development_dependency 'json'
29
- s.add_development_dependency "rspec", "~> 2.6"
30
- # s.add_development_dependency "lyberteam-gems-devel", "> 1.0.0"
29
+ s.add_development_dependency "rspec", "~> 3.0"
31
30
  s.add_development_dependency "yard"
32
31
 
33
32
  end
@@ -15,14 +15,14 @@ module Assembly
15
15
  # @param [Hash] params a hash containg parameters needed to produce content metadata
16
16
  # :druid = required - a string of druid of the repository object's druid id (with or without 'druid:' prefix)
17
17
  # :objects = required - an array of Assembly::ObjectFile objects containing the list of files to add to content metadata
18
- # NOTE: if you set the :bundle option to "prebundlded", you will need to pass in an array of arrays, and not a flat array, as noted below
18
+ # NOTE: if you set the :bundle option to :prebundled, you will need to pass in an array of arrays, and not a flat array, as noted below
19
19
  # :style = optional - a symbol containing the style of metadata to create, allowed values are
20
20
  # :simple_image (default), contentMetadata type="image", resource type="image"
21
21
  # :file, contentMetadata type="file", resource type="file"
22
22
  # :simple_book, contentMetadata type="book", resource type="page", but any resource which has file(s) other than an image, and also contains no images at all, will be resource type="object"
23
23
  # :book_with_pdf, contentMetadata type="book", resource type="page", but any resource which has any file(s) other than an image will be resource type="object"
24
24
  # :book_as_image, as simple_book, but with contentMetadata type="book", resource type="image" (same rule applies for resources with non images)
25
- # :map, like simple_image, but with contentMetadata type="map", resoruce type="image"
25
+ # :map, like simple_image, but with contentMetadata type="map", resource type="image"
26
26
  # :bundle = optional - a symbol containing the method of bundling files into resources, allowed values are
27
27
  # :default = all files get their own resources (default)
28
28
  # :filename = files with the same filename but different extensions get bundled together in a single resource
@@ -36,7 +36,7 @@ module Assembly
36
36
  # :include_root_xml = optional - a boolean to indicate if the contentMetadata returned includes a root <?xml version="1.0"?> tag, defaults to true
37
37
  # :preserve_common_paths = optional - When creating the file "id" attribute, content metadata uses the "relative_path" attribute of the ObjectFile objects passed in. If the "relative_path" attribute is not set, the "path" attribute is used instead,
38
38
  # which includes a full path to the file. If the "preserve_common_paths" parameter is set to false or left off, then the common paths of all of the ObjectFile's passed in are removed from any "path" attributes. This should turn full paths into
39
- # the relative paths that are required in content metadata file id nodes. If you do not want this behavior, set "preserve_common_paths" to true. The default it false.
39
+ # the relative paths that are required in content metadata file id nodes. If you do not want this behavior, set "preserve_common_paths" to true. The default is false.
40
40
  # :flatten_folder_structure = optional - Will remove *all* folder structure when genearting file IDs (e.g. DPG subfolders like '00','05' will be removed) when generating file IDs. This is useful if the folder structure is flattened when staging files (like for DPG).
41
41
  # The default is false. If set to true, will override the "preserve_common_paths" parameter.
42
42
  # :auto_labels = optional - Will add automated resource labels (e.g. "File 1") when labels are not provided by the user. The default is true.
@@ -79,15 +79,13 @@ module Assembly
79
79
  # a counter to use when creating auto-labels for resources, with incremenets for each type
80
80
  resource_type_counters=Hash.new(0)
81
81
 
82
- # set the content type id
82
+ # set the object level content type id
83
83
  case style
84
84
  when :simple_image
85
85
  content_type_description = content_type_descriptions[:image]
86
86
  when :file
87
87
  content_type_description = content_type_descriptions[:file]
88
- when :simple_book,:book_with_pdf
89
- content_type_description = content_type_descriptions[:book]
90
- when :book_as_image
88
+ when :simple_book,:book_with_pdf,:book_as_image
91
89
  content_type_description = content_type_descriptions[:book]
92
90
  when :map
93
91
  content_type_description = content_type_descriptions[:map]
@@ -33,6 +33,10 @@ module Assembly
33
33
  def initialize(path,params={})
34
34
  @path = path
35
35
  @label = params[:label]
36
+ @file_attributes = params[:file_attributes]
37
+ @relative_path = params[:relative_path]
38
+ @provider_md5 = params[:provide_md5]
39
+ @provider_sha1 = params[:provider_sha1]
36
40
  end
37
41
 
38
42
  # Returns base DPG name for the current file.
@@ -3,7 +3,7 @@ module Assembly
3
3
 
4
4
  class ObjectFile
5
5
  # Project version number
6
- VERSION = "1.6.7"
6
+ VERSION = "1.6.8"
7
7
  end
8
8
 
9
9
  end
@@ -5,36 +5,36 @@ describe Assembly::ContentMetadata do
5
5
  it "should generate valid content metadata with exif for a single tif and jp2 of style=simple_image, adding file attributes" do
6
6
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
7
7
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_exif=>true,:add_file_attributes=>true,:objects=>objects)
8
- result.class.should be String
8
+ expect(result.class).to be String
9
9
  xml = Nokogiri::XML(result)
10
- xml.errors.size.should be 0
11
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
12
- xml.xpath("//resource").length.should be 2
13
- xml.xpath("//resource/file").length.should be 2
14
- xml.xpath("//resource/file/checksum").length.should be 4
15
- xml.xpath("//resource/file/checksum")[0].text.should == "8d11fab63089a24c8b17063d29a4b0eac359fb41"
16
- xml.xpath("//resource/file/checksum")[1].text.should == "a2400500acf21e43f5440d93be894101"
17
- xml.xpath("//resource/file/checksum")[2].text.should == "b965b5787e0100ec2d43733144120feab327e88c"
18
- xml.xpath("//resource/file/checksum")[3].text.should == "4eb54050d374291ece622d45e84f014d"
19
- xml.xpath("//label").length.should be 2
20
- xml.xpath("//label")[0].text.should =~ /Image 1/
21
- xml.xpath("//label")[1].text.should =~ /Image 2/
22
- xml.xpath("//resource")[0].attributes['type'].value.should == "image"
23
- xml.xpath("//resource")[1].attributes['type'].value.should == "image"
24
- xml.xpath("//resource/file")[0].attributes['size'].value.should == "63542"
25
- xml.xpath("//resource/file")[0].attributes['mimetype'].value.should == "image/tiff"
26
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "no"
27
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "yes"
28
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no"
29
- xml.xpath("//resource/file/imageData")[0].attributes['width'].value.should == "100"
30
- xml.xpath("//resource/file/imageData")[0].attributes['height'].value.should == "100"
31
- xml.xpath("//resource/file")[1].attributes['size'].value.should == "306"
32
- xml.xpath("//resource/file")[1].attributes['mimetype'].value.should == "image/jp2"
33
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes"
34
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "no"
35
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes"
36
- xml.xpath("//resource/file/imageData")[1].attributes['width'].value.should == "100"
37
- xml.xpath("//resource/file/imageData")[1].attributes['height'].value.should == "100"
10
+ expect(xml.errors.size).to be 0
11
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
12
+ expect(xml.xpath("//resource").length).to be 2
13
+ expect(xml.xpath("//resource/file").length).to be 2
14
+ expect(xml.xpath("//resource/file/checksum").length).to be 4
15
+ expect(xml.xpath("//resource/file/checksum")[0].text).to eq("8d11fab63089a24c8b17063d29a4b0eac359fb41")
16
+ expect(xml.xpath("//resource/file/checksum")[1].text).to eq("a2400500acf21e43f5440d93be894101")
17
+ expect(xml.xpath("//resource/file/checksum")[2].text).to eq("b965b5787e0100ec2d43733144120feab327e88c")
18
+ expect(xml.xpath("//resource/file/checksum")[3].text).to eq("4eb54050d374291ece622d45e84f014d")
19
+ expect(xml.xpath("//label").length).to be 2
20
+ expect(xml.xpath("//label")[0].text).to match(/Image 1/)
21
+ expect(xml.xpath("//label")[1].text).to match(/Image 2/)
22
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
23
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
24
+ expect(xml.xpath("//resource/file")[0].attributes['size'].value).to eq("63542")
25
+ expect(xml.xpath("//resource/file")[0].attributes['mimetype'].value).to eq("image/tiff")
26
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("no")
27
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("yes")
28
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no")
29
+ expect(xml.xpath("//resource/file/imageData")[0].attributes['width'].value).to eq("100")
30
+ expect(xml.xpath("//resource/file/imageData")[0].attributes['height'].value).to eq("100")
31
+ expect(xml.xpath("//resource/file")[1].attributes['size'].value).to eq("306")
32
+ expect(xml.xpath("//resource/file")[1].attributes['mimetype'].value).to eq("image/jp2")
33
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes")
34
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("no")
35
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes")
36
+ expect(xml.xpath("//resource/file/imageData")[1].attributes['width'].value).to eq("100")
37
+ expect(xml.xpath("//resource/file/imageData")[1].attributes['height'].value).to eq("100")
38
38
  end
39
39
 
40
40
  it "should generate valid content metadata with no exif for a single tif and jp2 of style=simple_image, adding specific file attributes for 2 objects, and defaults for 1 object" do
@@ -45,173 +45,173 @@ describe Assembly::ContentMetadata do
45
45
  obj2.file_attributes={:publish=>'yes',:preserve=>'yes',:shelve=>'yes'}
46
46
  objects=[obj1,obj2,obj3]
47
47
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_exif=>false,:add_file_attributes=>true,:objects=>objects)
48
- result.class.should be String
48
+ expect(result.class).to be String
49
49
  xml = Nokogiri::XML(result)
50
- xml.errors.size.should be 0
51
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
52
- xml.xpath("//resource").length.should be 3
53
- xml.xpath("//resource/file").length.should be 3
54
- xml.xpath("//resource/file/checksum").length.should be 0
55
- xml.xpath("//resource/file/imageData").length.should be 0
56
- xml.xpath("//label").length.should be 3
57
- xml.xpath("//label")[0].text.should =~ /Image 1/
58
- xml.xpath("//label")[1].text.should =~ /Image 2/
59
- xml.xpath("//label")[2].text.should =~ /Image 3/
60
- xml.xpath("//resource")[0].attributes['type'].value.should == "image"
61
- xml.xpath("//resource")[1].attributes['type'].value.should == "image"
62
- xml.xpath("//resource")[2].attributes['type'].value.should == "image"
63
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "no" # specificially set in object
64
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "no" # specificially set in object
65
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no" # specificially set in object
66
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes" # specificially set in object
67
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "yes" # specificially set in object
68
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes" # specificially set in object
69
- xml.xpath("//resource/file")[2].attributes['publish'].value.should == "yes" # defaults by mimetype
70
- xml.xpath("//resource/file")[2].attributes['preserve'].value.should == "no" # defaults by mimetype
71
- xml.xpath("//resource/file")[2].attributes['shelve'].value.should == "yes" # defaults by mimetype
50
+ expect(xml.errors.size).to be 0
51
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
52
+ expect(xml.xpath("//resource").length).to be 3
53
+ expect(xml.xpath("//resource/file").length).to be 3
54
+ expect(xml.xpath("//resource/file/checksum").length).to be 0
55
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
56
+ expect(xml.xpath("//label").length).to be 3
57
+ expect(xml.xpath("//label")[0].text).to match(/Image 1/)
58
+ expect(xml.xpath("//label")[1].text).to match(/Image 2/)
59
+ expect(xml.xpath("//label")[2].text).to match(/Image 3/)
60
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
61
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
62
+ expect(xml.xpath("//resource")[2].attributes['type'].value).to eq("image")
63
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("no") # specificially set in object
64
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("no") # specificially set in object
65
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no") # specificially set in object
66
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes") # specificially set in object
67
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("yes") # specificially set in object
68
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes") # specificially set in object
69
+ expect(xml.xpath("//resource/file")[2].attributes['publish'].value).to eq("yes") # defaults by mimetype
70
+ expect(xml.xpath("//resource/file")[2].attributes['preserve'].value).to eq("no") # defaults by mimetype
71
+ expect(xml.xpath("//resource/file")[2].attributes['shelve'].value).to eq("yes") # defaults by mimetype
72
72
  end
73
73
 
74
74
 
75
75
  it "should generate valid content metadata with exif for a single tif and jp2 of style=simple_image overriding file labels" do
76
76
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE,:label=>'Sample tif label!'),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE,:label=>'Sample jp2 label!')]
77
77
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_exif=>true,:add_file_attributes=>true,:objects=>objects)
78
- result.class.should be String
78
+ expect(result.class).to be String
79
79
  xml = Nokogiri::XML(result)
80
- xml.errors.size.should be 0
81
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
82
- xml.xpath("//resource").length.should be 2
83
- xml.xpath("//resource/file").length.should be 2
84
- xml.xpath("//resource/file/checksum").length.should be 4
85
- xml.xpath("//resource/file/checksum")[0].text.should == "8d11fab63089a24c8b17063d29a4b0eac359fb41"
86
- xml.xpath("//resource/file/checksum")[1].text.should == "a2400500acf21e43f5440d93be894101"
87
- xml.xpath("//resource/file/checksum")[2].text.should == "b965b5787e0100ec2d43733144120feab327e88c"
88
- xml.xpath("//resource/file/checksum")[3].text.should == "4eb54050d374291ece622d45e84f014d"
89
- xml.xpath("//label").length.should be 2
90
- xml.xpath("//label")[0].text.should =~ /Sample tif label!/
91
- xml.xpath("//label")[1].text.should =~ /Sample jp2 label!/
92
- xml.xpath("//resource")[0].attributes['type'].value.should == "image"
93
- xml.xpath("//resource")[1].attributes['type'].value.should == "image"
94
- xml.xpath("//resource/file")[0].attributes['size'].value.should == "63542"
95
- xml.xpath("//resource/file")[0].attributes['mimetype'].value.should == "image/tiff"
96
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "no"
97
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "yes"
98
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no"
99
- xml.xpath("//resource/file/imageData")[0].attributes['width'].value.should == "100"
100
- xml.xpath("//resource/file/imageData")[0].attributes['height'].value.should == "100"
101
- xml.xpath("//resource/file")[1].attributes['size'].value.should == "306"
102
- xml.xpath("//resource/file")[1].attributes['mimetype'].value.should == "image/jp2"
103
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes"
104
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "no"
105
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes"
106
- xml.xpath("//resource/file/imageData")[1].attributes['width'].value.should == "100"
107
- xml.xpath("//resource/file/imageData")[1].attributes['height'].value.should == "100"
80
+ expect(xml.errors.size).to be 0
81
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
82
+ expect(xml.xpath("//resource").length).to be 2
83
+ expect(xml.xpath("//resource/file").length).to be 2
84
+ expect(xml.xpath("//resource/file/checksum").length).to be 4
85
+ expect(xml.xpath("//resource/file/checksum")[0].text).to eq("8d11fab63089a24c8b17063d29a4b0eac359fb41")
86
+ expect(xml.xpath("//resource/file/checksum")[1].text).to eq("a2400500acf21e43f5440d93be894101")
87
+ expect(xml.xpath("//resource/file/checksum")[2].text).to eq("b965b5787e0100ec2d43733144120feab327e88c")
88
+ expect(xml.xpath("//resource/file/checksum")[3].text).to eq("4eb54050d374291ece622d45e84f014d")
89
+ expect(xml.xpath("//label").length).to be 2
90
+ expect(xml.xpath("//label")[0].text).to match(/Sample tif label!/)
91
+ expect(xml.xpath("//label")[1].text).to match(/Sample jp2 label!/)
92
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
93
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
94
+ expect(xml.xpath("//resource/file")[0].attributes['size'].value).to eq("63542")
95
+ expect(xml.xpath("//resource/file")[0].attributes['mimetype'].value).to eq("image/tiff")
96
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("no")
97
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("yes")
98
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no")
99
+ expect(xml.xpath("//resource/file/imageData")[0].attributes['width'].value).to eq("100")
100
+ expect(xml.xpath("//resource/file/imageData")[0].attributes['height'].value).to eq("100")
101
+ expect(xml.xpath("//resource/file")[1].attributes['size'].value).to eq("306")
102
+ expect(xml.xpath("//resource/file")[1].attributes['mimetype'].value).to eq("image/jp2")
103
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes")
104
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("no")
105
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes")
106
+ expect(xml.xpath("//resource/file/imageData")[1].attributes['width'].value).to eq("100")
107
+ expect(xml.xpath("//resource/file/imageData")[1].attributes['height'].value).to eq("100")
108
108
  end
109
109
 
110
110
  it "should generate valid content metadata with exif for a single tif and jp2 of style=simple_image overriding file labels for one, and skipping auto labels for the others or for where the label is set but is blank" do
111
111
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE,:label=>'Sample tif label!'),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE,:label=>'')]
112
112
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:auto_labels=>false,:add_file_attributes=>true,:objects=>objects)
113
- result.class.should be String
113
+ expect(result.class).to be String
114
114
  xml = Nokogiri::XML(result)
115
- xml.errors.size.should be 0
116
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
117
- xml.xpath("//resource").length.should be 3
118
- xml.xpath("//resource/file").length.should be 3
119
- xml.xpath("//label").length.should be 1
120
- xml.xpath("//label")[0].text.should =~ /Sample tif label!/
115
+ expect(xml.errors.size).to be 0
116
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
117
+ expect(xml.xpath("//resource").length).to be 3
118
+ expect(xml.xpath("//resource/file").length).to be 3
119
+ expect(xml.xpath("//label").length).to be 1
120
+ expect(xml.xpath("//label")[0].text).to match(/Sample tif label!/)
121
121
  end
122
122
 
123
123
  it "should generate valid content metadata for a single tif and jp2 of style=simple_image with overriding file attributes and no exif data" do
124
124
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
125
125
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_file_attributes=>true,:file_attributes=>{'image/tiff'=>{:publish=>'no',:preserve=>'no',:shelve=>'no'},'image/jp2'=>{:publish=>'yes',:preserve=>'yes',:shelve=>'yes'}},:objects=>objects)
126
- result.class.should be String
126
+ expect(result.class).to be String
127
127
  xml = Nokogiri::XML(result)
128
- xml.errors.size.should be 0
129
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
130
- xml.xpath("//resource").length.should be 2
131
- xml.xpath("//resource/file").length.should be 2
132
- xml.xpath("//label").length.should be 2
133
- xml.xpath("//resource/file/imageData").length.should be 0
134
- xml.xpath("//label")[0].text.should =~ /Image 1/
135
- xml.xpath("//label")[1].text.should =~ /Image 2/
136
- xml.xpath("//resource")[0].attributes['type'].value.should == "image"
137
- xml.xpath("//resource")[1].attributes['type'].value.should == "image"
138
- xml.xpath("//resource/file")[0].attributes['size'].should be nil
139
- xml.xpath("//resource/file")[0].attributes['mimetype'].should be nil
140
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "no"
141
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "no"
142
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no"
143
- xml.xpath("//resource/file")[1].attributes['size'].should be nil
144
- xml.xpath("//resource/file")[1].attributes['mimetype'].should be nil
145
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes"
146
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "yes"
147
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes"
128
+ expect(xml.errors.size).to be 0
129
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
130
+ expect(xml.xpath("//resource").length).to be 2
131
+ expect(xml.xpath("//resource/file").length).to be 2
132
+ expect(xml.xpath("//label").length).to be 2
133
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
134
+ expect(xml.xpath("//label")[0].text).to match(/Image 1/)
135
+ expect(xml.xpath("//label")[1].text).to match(/Image 2/)
136
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
137
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
138
+ expect(xml.xpath("//resource/file")[0].attributes['size']).to be nil
139
+ expect(xml.xpath("//resource/file")[0].attributes['mimetype']).to be nil
140
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("no")
141
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("no")
142
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no")
143
+ expect(xml.xpath("//resource/file")[1].attributes['size']).to be nil
144
+ expect(xml.xpath("//resource/file")[1].attributes['mimetype']).to be nil
145
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes")
146
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("yes")
147
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes")
148
148
  end
149
149
 
150
150
  it "should generate valid content metadata for a single tif and jp2 of style=simple_image with overriding file attributes, including a default value, and no exif data" do
151
151
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
152
152
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:add_file_attributes=>true,:file_attributes=>{'default'=>{:publish=>'yes',:preserve=>'no',:shelve=>'no'},'image/jp2'=>{:publish=>'yes',:preserve=>'yes',:shelve=>'yes'}},:objects=>objects)
153
- result.class.should be String
153
+ expect(result.class).to be String
154
154
  xml = Nokogiri::XML(result)
155
- xml.errors.size.should be 0
156
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
157
- xml.xpath("//resource/file").length.should be 2
158
- xml.xpath("//resource/file")[0].attributes['mimetype'].should be nil
159
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "yes"
160
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "no"
161
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no"
162
- xml.xpath("//resource/file")[1].attributes['mimetype'].should be nil
163
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes"
164
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "yes"
165
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes"
155
+ expect(xml.errors.size).to be 0
156
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
157
+ expect(xml.xpath("//resource/file").length).to be 2
158
+ expect(xml.xpath("//resource/file")[0].attributes['mimetype']).to be nil
159
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("yes")
160
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("no")
161
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no")
162
+ expect(xml.xpath("//resource/file")[1].attributes['mimetype']).to be nil
163
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes")
164
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("yes")
165
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes")
166
166
  for i in 0..1 do
167
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 1
168
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
169
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
167
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
168
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
169
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
170
170
  end
171
171
  end
172
172
 
173
173
  it "should generate valid content metadata for a single tif and jp2 of style=map with overriding file attributes, including a default value, and no exif data" do
174
174
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE)]
175
175
  result = Assembly::ContentMetadata.create_content_metadata(:style=>:map,:druid=>TEST_DRUID,:add_file_attributes=>true,:file_attributes=>{'default'=>{:publish=>'yes',:preserve=>'no',:shelve=>'no'},'image/jp2'=>{:publish=>'yes',:preserve=>'yes',:shelve=>'yes'}},:objects=>objects)
176
- result.class.should be String
176
+ expect(result.class).to be String
177
177
  xml = Nokogiri::XML(result)
178
- xml.errors.size.should be 0
179
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "map"
180
- xml.xpath("//resource/file").length.should be 2
181
- xml.xpath("//resource/file")[0].attributes['mimetype'].should be nil
182
- xml.xpath("//resource/file")[0].attributes['publish'].value.should == "yes"
183
- xml.xpath("//resource/file")[0].attributes['preserve'].value.should == "no"
184
- xml.xpath("//resource/file")[0].attributes['shelve'].value.should == "no"
185
- xml.xpath("//resource/file")[1].attributes['mimetype'].should be nil
186
- xml.xpath("//resource/file")[1].attributes['publish'].value.should == "yes"
187
- xml.xpath("//resource/file")[1].attributes['preserve'].value.should == "yes"
188
- xml.xpath("//resource/file")[1].attributes['shelve'].value.should == "yes"
178
+ expect(xml.errors.size).to be 0
179
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("map")
180
+ expect(xml.xpath("//resource/file").length).to be 2
181
+ expect(xml.xpath("//resource/file")[0].attributes['mimetype']).to be nil
182
+ expect(xml.xpath("//resource/file")[0].attributes['publish'].value).to eq("yes")
183
+ expect(xml.xpath("//resource/file")[0].attributes['preserve'].value).to eq("no")
184
+ expect(xml.xpath("//resource/file")[0].attributes['shelve'].value).to eq("no")
185
+ expect(xml.xpath("//resource/file")[1].attributes['mimetype']).to be nil
186
+ expect(xml.xpath("//resource/file")[1].attributes['publish'].value).to eq("yes")
187
+ expect(xml.xpath("//resource/file")[1].attributes['preserve'].value).to eq("yes")
188
+ expect(xml.xpath("//resource/file")[1].attributes['shelve'].value).to eq("yes")
189
189
  for i in 0..1 do
190
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 1
191
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
192
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
190
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
191
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
192
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
193
193
  end
194
194
  end
195
195
 
196
196
  it "should generate valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=filename and no exif data" do
197
197
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
198
198
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:filename,:objects=>objects)
199
- result.class.should be String
199
+ expect(result.class).to be String
200
200
  xml = Nokogiri::XML(result)
201
- xml.errors.size.should be 0
202
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
203
- xml.xpath("//resource").length.should be 2
204
- xml.xpath("//resource/file").length.should be 4
205
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == 'test.tif'
206
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == 'test.jp2'
207
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == 'test2.tif'
208
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == 'test2.jp2'
209
- xml.xpath("//label").length.should be 2
210
- xml.xpath("//resource/file/imageData").length.should be 0
201
+ expect(xml.errors.size).to be 0
202
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
203
+ expect(xml.xpath("//resource").length).to be 2
204
+ expect(xml.xpath("//resource/file").length).to be 4
205
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('test.tif')
206
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('test.jp2')
207
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('test2.tif')
208
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('test2.jp2')
209
+ expect(xml.xpath("//label").length).to be 2
210
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
211
211
  for i in 0..1 do
212
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 2
213
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
214
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
212
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
213
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
214
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
215
215
  end
216
216
  end
217
217
 
@@ -219,162 +219,162 @@ describe Assembly::ContentMetadata do
219
219
  objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2)]
220
220
  test_druid="#{TEST_DRUID}"
221
221
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>test_druid,:bundle=>:dpg,:objects=>objects,:include_root_xml=>false)
222
- result.class.should be String
223
- result.include?('<?xml').should be false
222
+ expect(result.class).to be String
223
+ expect(result.include?('<?xml')).to be false
224
224
  xml = Nokogiri::XML(result)
225
- xml.errors.size.should be 0
226
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
227
- test_druid.should == TEST_DRUID
228
- xml.xpath("//contentMetadata")[0].attributes['objectId'].value.should == "#{TEST_DRUID}"
229
- xml.xpath("//resource").length.should be 2
230
- xml.xpath("//resource/file").length.should be 4
231
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == "00/oo000oo0001_00_001.tif"
232
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == "05/oo000oo0001_05_001.jp2"
233
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == "00/oo000oo0001_00_002.tif"
234
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == "05/oo000oo0001_05_002.jp2"
235
- xml.xpath("//label").length.should be 2
236
- xml.xpath("//resource/file/imageData").length.should be 0
225
+ expect(xml.errors.size).to be 0
226
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
227
+ expect(test_druid).to eq(TEST_DRUID)
228
+ expect(xml.xpath("//contentMetadata")[0].attributes['objectId'].value).to eq("#{TEST_DRUID}")
229
+ expect(xml.xpath("//resource").length).to be 2
230
+ expect(xml.xpath("//resource/file").length).to be 4
231
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq("00/oo000oo0001_00_001.tif")
232
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq("05/oo000oo0001_05_001.jp2")
233
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq("00/oo000oo0001_00_002.tif")
234
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq("05/oo000oo0001_05_002.jp2")
235
+ expect(xml.xpath("//label").length).to be 2
236
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
237
237
  for i in 0..1 do
238
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 2
239
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
240
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
238
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
239
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
240
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
241
241
  end
242
242
  end
243
243
 
244
244
  it "should generate valid content metadata for two tifs, two associated jp2s, one combined pdf and one special tif of style=simple_book using bundle=dpg and no exif data and no root xml node, flattening folder structure" do
245
245
  objects=[Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_TIF),Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2)]
246
246
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:simple_book,:bundle=>:dpg,:objects=>objects,:include_root_xml=>false,:flatten_folder_structure=>true)
247
- result.class.should be String
248
- result.include?('<?xml').should be false
247
+ expect(result.class).to be String
248
+ expect(result.include?('<?xml')).to be false
249
249
  xml = Nokogiri::XML(result)
250
- xml.errors.size.should be 0
251
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
252
- xml.xpath("//contentMetadata")[0].attributes['objectId'].value.should == "#{TEST_DRUID}"
253
- xml.xpath("//resource").length.should be 4
254
- xml.xpath("//resource/file").length.should be 6
255
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == "oo000oo0001_00_001.tif"
256
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == "oo000oo0001_05_001.jp2"
257
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == "oo000oo0001_00_002.tif"
258
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == "oo000oo0001_05_002.jp2"
259
- xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value.should == "oo000oo0001_31_001.pdf"
260
- xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value.should == "oo000oo0001_50_001.tif"
261
- xml.xpath("//label").length.should be 4
262
- xml.xpath("//resource/file/imageData").length.should be 0
250
+ expect(xml.errors.size).to be 0
251
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
252
+ expect(xml.xpath("//contentMetadata")[0].attributes['objectId'].value).to eq("#{TEST_DRUID}")
253
+ expect(xml.xpath("//resource").length).to be 4
254
+ expect(xml.xpath("//resource/file").length).to be 6
255
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq("oo000oo0001_00_001.tif")
256
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq("oo000oo0001_05_001.jp2")
257
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq("oo000oo0001_00_002.tif")
258
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq("oo000oo0001_05_002.jp2")
259
+ expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq("oo000oo0001_31_001.pdf")
260
+ expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq("oo000oo0001_50_001.tif")
261
+ expect(xml.xpath("//label").length).to be 4
262
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
263
263
  for i in 0..1 do
264
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 2
265
- xml.xpath("//label")[i].text.should == "Page #{i+1}"
266
- xml.xpath("//resource")[i].attributes['type'].value.should == "page"
264
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 2
265
+ expect(xml.xpath("//label")[i].text).to eq("Page #{i+1}")
266
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("page")
267
267
  end
268
- xml.xpath("//resource[@sequence='3']/file").length.should be 1
269
- xml.xpath("//label")[2].text.should == "Object 1"
270
- xml.xpath("//resource")[2].attributes['type'].value.should == "object"
271
- xml.xpath("//resource[@sequence='4']/file").length.should be 1
272
- xml.xpath("//label")[3].text.should == "Object 2"
273
- xml.xpath("//resource")[3].attributes['type'].value.should == "object"
268
+ expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
269
+ expect(xml.xpath("//label")[2].text).to eq("Object 1")
270
+ expect(xml.xpath("//resource")[2].attributes['type'].value).to eq("object")
271
+ expect(xml.xpath("//resource[@sequence='4']/file").length).to be 1
272
+ expect(xml.xpath("//label")[3].text).to eq("Object 2")
273
+ expect(xml.xpath("//resource")[3].attributes['type'].value).to eq("object")
274
274
  end
275
275
 
276
276
  it "should generate valid content metadata with item having a 'druid:' prefix for two tifs,two associated jp2s,two associated pdfs, and one lingering PDF of style=simple_book using bundle=dpg, flattening folder structure" do
277
277
  objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_PDF),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2),Assembly::ObjectFile.new(TEST_DPG_PDF2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
278
278
  test_druid="druid:#{TEST_DRUID}"
279
279
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>test_druid,:bundle=>:dpg,:objects=>objects,:style=>:simple_book,:flatten_folder_structure=>true)
280
- result.class.should be String
281
- result.include?('<?xml').should be true
280
+ expect(result.class).to be String
281
+ expect(result.include?('<?xml')).to be true
282
282
  xml = Nokogiri::XML(result)
283
- xml.errors.size.should be 0
284
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
285
- xml.xpath("//contentMetadata")[0].attributes['objectId'].value.should == test_druid
286
- test_druid.should == "druid:#{TEST_DRUID}"
287
- xml.xpath("//resource").length.should be 3
288
- xml.xpath("//resource/file").length.should be 7
283
+ expect(xml.errors.size).to be 0
284
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
285
+ expect(xml.xpath("//contentMetadata")[0].attributes['objectId'].value).to eq(test_druid)
286
+ expect(test_druid).to eq("druid:#{TEST_DRUID}")
287
+ expect(xml.xpath("//resource").length).to be 3
288
+ expect(xml.xpath("//resource/file").length).to be 7
289
289
 
290
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == "oo000oo0001_00_001.tif"
291
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == "oo000oo0001_05_001.jp2"
292
- xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value.should == "oo000oo0001_15_001.pdf"
293
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == "oo000oo0001_00_002.tif"
294
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == "oo000oo0001_05_002.jp2"
295
- xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value.should == "oo000oo0001_15_002.pdf"
296
- xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value.should == "oo000oo0001_book.pdf"
297
- xml.xpath("//label").length.should be 3
298
- xml.xpath("//resource/file/imageData").length.should be 0
290
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq("oo000oo0001_00_001.tif")
291
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq("oo000oo0001_05_001.jp2")
292
+ expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq("oo000oo0001_15_001.pdf")
293
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq("oo000oo0001_00_002.tif")
294
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq("oo000oo0001_05_002.jp2")
295
+ expect(xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value).to eq("oo000oo0001_15_002.pdf")
296
+ expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq("oo000oo0001_book.pdf")
297
+ expect(xml.xpath("//label").length).to be 3
298
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
299
299
  for i in 0..1 do
300
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 3
301
- xml.xpath("//label")[i].text.should == "Page #{i+1}"
302
- xml.xpath("//resource")[i].attributes['type'].value.should == "page"
300
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 3
301
+ expect(xml.xpath("//label")[i].text).to eq("Page #{i+1}")
302
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("page")
303
303
  end
304
- xml.xpath("//resource[@sequence='3']/file").length.should be 1
305
- xml.xpath("//label")[2].text.should == "Object 1"
306
- xml.xpath("//resource")[2].attributes['type'].value.should == "object"
304
+ expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
305
+ expect(xml.xpath("//label")[2].text).to eq("Object 1")
306
+ expect(xml.xpath("//resource")[2].attributes['type'].value).to eq("object")
307
307
  end
308
308
 
309
309
  it "should generate valid content metadata for two tifs,two associated jp2s,two associated pdfs, and one lingering PDF of style=book_with_pdf using bundle=dpg" do
310
310
  objects=[Assembly::ObjectFile.new(TEST_DPG_TIF),Assembly::ObjectFile.new(TEST_DPG_JP),Assembly::ObjectFile.new(TEST_DPG_PDF),Assembly::ObjectFile.new(TEST_DPG_TIF2),Assembly::ObjectFile.new(TEST_DPG_JP2),Assembly::ObjectFile.new(TEST_DPG_SPECIAL_PDF1)]
311
311
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:dpg,:objects=>objects,:style=>:book_with_pdf)
312
- result.class.should be String
312
+ expect(result.class).to be String
313
313
  xml = Nokogiri::XML(result)
314
- xml.errors.size.should be 0
315
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
316
- xml.xpath("//resource").length.should be 3
317
- xml.xpath("//resource/file").length.should be 6
318
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == "00/oo000oo0001_00_001.tif"
319
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == "05/oo000oo0001_05_001.jp2"
320
- xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value.should == "15/oo000oo0001_15_001.pdf"
321
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == "00/oo000oo0001_00_002.tif"
322
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == "05/oo000oo0001_05_002.jp2"
323
- xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value.should == "oo000oo0001_book.pdf"
324
- xml.xpath("//label").length.should be 3
325
- xml.xpath("//resource/file/imageData").length.should be 0
326
- xml.xpath("//resource[@sequence='1']/file").length.should be 3
327
- xml.xpath("//label")[0].text.should == "Object 1"
328
- xml.xpath("//resource")[0].attributes['type'].value.should == "object"
329
- xml.xpath("//resource[@sequence='2']/file").length.should be 2
330
- xml.xpath("//label")[1].text.should == "Page 1"
331
- xml.xpath("//resource")[1].attributes['type'].value.should == "page"
332
- xml.xpath("//resource[@sequence='3']/file").length.should be 1
333
- xml.xpath("//label")[2].text.should == "Object 2"
334
- xml.xpath("//resource")[2].attributes['type'].value.should == "object"
314
+ expect(xml.errors.size).to be 0
315
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
316
+ expect(xml.xpath("//resource").length).to be 3
317
+ expect(xml.xpath("//resource/file").length).to be 6
318
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq("00/oo000oo0001_00_001.tif")
319
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq("05/oo000oo0001_05_001.jp2")
320
+ expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq("15/oo000oo0001_15_001.pdf")
321
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq("00/oo000oo0001_00_002.tif")
322
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq("05/oo000oo0001_05_002.jp2")
323
+ expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq("oo000oo0001_book.pdf")
324
+ expect(xml.xpath("//label").length).to be 3
325
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
326
+ expect(xml.xpath("//resource[@sequence='1']/file").length).to be 3
327
+ expect(xml.xpath("//label")[0].text).to eq("Object 1")
328
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("object")
329
+ expect(xml.xpath("//resource[@sequence='2']/file").length).to be 2
330
+ expect(xml.xpath("//label")[1].text).to eq("Page 1")
331
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("page")
332
+ expect(xml.xpath("//resource[@sequence='3']/file").length).to be 1
333
+ expect(xml.xpath("//label")[2].text).to eq("Object 2")
334
+ expect(xml.xpath("//resource")[2].attributes['type'].value).to eq("object")
335
335
  end
336
336
 
337
337
  it "should generate valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=default and no exif data" do
338
338
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
339
339
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:default,:objects=>objects)
340
- result.class.should be String
340
+ expect(result.class).to be String
341
341
  xml = Nokogiri::XML(result)
342
- xml.errors.size.should be 0
343
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
344
- xml.xpath("//resource").length.should be 4
345
- xml.xpath("//resource/file").length.should be 4
346
- xml.xpath("//resource/file")[0].attributes['id'].value.should == 'test.tif'
347
- xml.xpath("//resource/file")[1].attributes['id'].value.should == 'test.jp2'
348
- xml.xpath("//resource/file")[2].attributes['id'].value.should == 'test2.tif'
349
- xml.xpath("//resource/file")[3].attributes['id'].value.should == 'test2.jp2'
350
- xml.xpath("//label").length.should be 4
351
- xml.xpath("//resource/file/imageData").length.should be 0
342
+ expect(xml.errors.size).to be 0
343
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
344
+ expect(xml.xpath("//resource").length).to be 4
345
+ expect(xml.xpath("//resource/file").length).to be 4
346
+ expect(xml.xpath("//resource/file")[0].attributes['id'].value).to eq('test.tif')
347
+ expect(xml.xpath("//resource/file")[1].attributes['id'].value).to eq('test.jp2')
348
+ expect(xml.xpath("//resource/file")[2].attributes['id'].value).to eq('test2.tif')
349
+ expect(xml.xpath("//resource/file")[3].attributes['id'].value).to eq('test2.jp2')
350
+ expect(xml.xpath("//label").length).to be 4
351
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
352
352
  for i in 0..3 do
353
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 1
354
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
355
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
353
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
354
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
355
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
356
356
  end
357
357
  end
358
358
 
359
359
  it "should generate valid content metadata for two tifs two associated jp2s of style=simple_image using bundle=default and no exif data, preserving full paths" do
360
360
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_JP2_INPUT_FILE2)]
361
361
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:default,:objects=>objects,:preserve_common_paths=>true)
362
- result.class.should be String
362
+ expect(result.class).to be String
363
363
  xml = Nokogiri::XML(result)
364
- xml.errors.size.should be 0
365
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
366
- xml.xpath("//resource").length.should be 4
367
- xml.xpath("//resource/file").length.should be 4
368
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == TEST_TIF_INPUT_FILE
369
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == TEST_JP2_INPUT_FILE
370
- xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value.should == TEST_TIF_INPUT_FILE2
371
- xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value.should == TEST_JP2_INPUT_FILE2
372
- xml.xpath("//label").length.should be 4
373
- xml.xpath("//resource/file/imageData").length.should be 0
364
+ expect(xml.errors.size).to be 0
365
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
366
+ expect(xml.xpath("//resource").length).to be 4
367
+ expect(xml.xpath("//resource/file").length).to be 4
368
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq(TEST_TIF_INPUT_FILE)
369
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq(TEST_JP2_INPUT_FILE)
370
+ expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq(TEST_TIF_INPUT_FILE2)
371
+ expect(xml.xpath("//resource[@sequence='4']/file")[0].attributes['id'].value).to eq(TEST_JP2_INPUT_FILE2)
372
+ expect(xml.xpath("//label").length).to be 4
373
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
374
374
  for i in 0..3 do
375
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 1
376
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
377
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
375
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
376
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
377
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
378
378
  end
379
379
  end
380
380
 
@@ -385,89 +385,89 @@ describe Assembly::ContentMetadata do
385
385
  objects[2].relative_path='input/test2.tif'
386
386
  objects[3].relative_path='input/test2.jp2'
387
387
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:file,:objects=>objects)
388
- result.class.should be String
388
+ expect(result.class).to be String
389
389
  xml = Nokogiri::XML(result)
390
- xml.errors.size.should be 0
391
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "file"
392
- xml.xpath("//resource").length.should be 4
393
- xml.xpath("//resource/file").length.should be 4
394
- xml.xpath("//label").length.should be 4
395
- xml.xpath("//resource/file")[0].attributes['id'].value.should == 'input/test.tif'
396
- xml.xpath("//resource/file")[1].attributes['id'].value.should == 'input/test.jp2'
397
- xml.xpath("//resource/file")[2].attributes['id'].value.should == 'input/test2.tif'
398
- xml.xpath("//resource/file")[3].attributes['id'].value.should == 'input/test2.jp2'
390
+ expect(xml.errors.size).to be 0
391
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("file")
392
+ expect(xml.xpath("//resource").length).to be 4
393
+ expect(xml.xpath("//resource/file").length).to be 4
394
+ expect(xml.xpath("//label").length).to be 4
395
+ expect(xml.xpath("//resource/file")[0].attributes['id'].value).to eq('input/test.tif')
396
+ expect(xml.xpath("//resource/file")[1].attributes['id'].value).to eq('input/test.jp2')
397
+ expect(xml.xpath("//resource/file")[2].attributes['id'].value).to eq('input/test2.tif')
398
+ expect(xml.xpath("//resource/file")[3].attributes['id'].value).to eq('input/test2.jp2')
399
399
  for i in 0..3 do
400
- xml.xpath("//resource[@sequence='#{i+1}']/file").length.should be 1
401
- xml.xpath("//label")[i].text.should == "File #{i+1}"
402
- xml.xpath("//resource")[i].attributes['type'].value.should == "file"
400
+ expect(xml.xpath("//resource[@sequence='#{i+1}']/file").length).to be 1
401
+ expect(xml.xpath("//label")[i].text).to eq("File #{i+1}")
402
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("file")
403
403
  end
404
404
  end
405
405
 
406
406
  it "should generate valid content metadata for two tifs of style=simple_book" do
407
407
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
408
408
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:simple_book,:objects=>objects)
409
- result.class.should be String
409
+ expect(result.class).to be String
410
410
  xml = Nokogiri::XML(result)
411
- xml.errors.size.should be 0
412
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
413
- xml.xpath("//resource").length.should be 2
414
- xml.xpath("//resource/file").length.should be 2
415
- xml.xpath("//label").length.should be 2
416
- xml.xpath("//label")[0].text.should =~ /Page 1/
417
- xml.xpath("//label")[1].text.should =~ /Page 2/
418
- xml.xpath("//resource/file/imageData").length.should be 0
411
+ expect(xml.errors.size).to be 0
412
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
413
+ expect(xml.xpath("//resource").length).to be 2
414
+ expect(xml.xpath("//resource/file").length).to be 2
415
+ expect(xml.xpath("//label").length).to be 2
416
+ expect(xml.xpath("//label")[0].text).to match(/Page 1/)
417
+ expect(xml.xpath("//label")[1].text).to match(/Page 2/)
418
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
419
419
  for i in 0..1 do
420
- xml.xpath("//resource/file")[i].attributes['size'].should be nil
421
- xml.xpath("//resource/file")[i].attributes['mimetype'].should be nil
422
- xml.xpath("//resource/file")[i].attributes['publish'].should be nil
423
- xml.xpath("//resource/file")[i].attributes['preserve'].should be nil
424
- xml.xpath("//resource/file")[i].attributes['shelve'].should be nil
420
+ expect(xml.xpath("//resource/file")[i].attributes['size']).to be nil
421
+ expect(xml.xpath("//resource/file")[i].attributes['mimetype']).to be nil
422
+ expect(xml.xpath("//resource/file")[i].attributes['publish']).to be nil
423
+ expect(xml.xpath("//resource/file")[i].attributes['preserve']).to be nil
424
+ expect(xml.xpath("//resource/file")[i].attributes['shelve']).to be nil
425
425
  end
426
- xml.xpath("//resource")[0].attributes['type'].value.should == "page"
427
- xml.xpath("//resource")[1].attributes['type'].value.should == "page"
426
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("page")
427
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("page")
428
428
  end
429
429
 
430
430
  it "should generate valid content metadata for two tifs and one pdf of style=book_with_pdf" do
431
431
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2),Assembly::ObjectFile.new(TEST_PDF_FILE)]
432
432
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:book_with_pdf,:objects=>objects)
433
- result.class.should be String
433
+ expect(result.class).to be String
434
434
  xml = Nokogiri::XML(result)
435
- xml.errors.size.should be 0
436
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
437
- xml.xpath("//resource").length.should be 3
438
- xml.xpath("//resource/file").length.should be 3
439
- xml.xpath("//label").length.should be 3
440
- xml.xpath("//label")[0].text.should =~ /Page 1/
441
- xml.xpath("//label")[1].text.should =~ /Page 2/
442
- xml.xpath("//label")[2].text.should =~ /Object 1/
443
- xml.xpath("//resource/file/imageData").length.should be 0
444
- xml.xpath("//resource")[0].attributes['type'].value.should == "page"
445
- xml.xpath("//resource")[1].attributes['type'].value.should == "page"
446
- xml.xpath("//resource")[2].attributes['type'].value.should == "object"
435
+ expect(xml.errors.size).to be 0
436
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
437
+ expect(xml.xpath("//resource").length).to be 3
438
+ expect(xml.xpath("//resource/file").length).to be 3
439
+ expect(xml.xpath("//label").length).to be 3
440
+ expect(xml.xpath("//label")[0].text).to match(/Page 1/)
441
+ expect(xml.xpath("//label")[1].text).to match(/Page 2/)
442
+ expect(xml.xpath("//label")[2].text).to match(/Object 1/)
443
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
444
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("page")
445
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("page")
446
+ expect(xml.xpath("//resource")[2].attributes['type'].value).to eq("object")
447
447
  end
448
448
 
449
449
  it "should generate valid content metadata for two tifs of style=book_as_image" do
450
450
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE2)]
451
451
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:book_as_image,:objects=>objects)
452
- result.class.should be String
452
+ expect(result.class).to be String
453
453
  xml = Nokogiri::XML(result)
454
- xml.errors.size.should be 0
455
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
456
- xml.xpath("//resource").length.should be 2
457
- xml.xpath("//resource/file").length.should be 2
458
- xml.xpath("//label").length.should be 2
459
- xml.xpath("//label")[0].text.should =~ /Image 1/
460
- xml.xpath("//label")[1].text.should =~ /Image 2/
461
- xml.xpath("//resource/file/imageData").length.should be 0
454
+ expect(xml.errors.size).to be 0
455
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
456
+ expect(xml.xpath("//resource").length).to be 2
457
+ expect(xml.xpath("//resource/file").length).to be 2
458
+ expect(xml.xpath("//label").length).to be 2
459
+ expect(xml.xpath("//label")[0].text).to match(/Image 1/)
460
+ expect(xml.xpath("//label")[1].text).to match(/Image 2/)
461
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
462
462
  for i in 0..1 do
463
- xml.xpath("//resource/file")[i].attributes['size'].should be nil
464
- xml.xpath("//resource/file")[i].attributes['mimetype'].should be nil
465
- xml.xpath("//resource/file")[i].attributes['publish'].should be nil
466
- xml.xpath("//resource/file")[i].attributes['preserve'].should be nil
467
- xml.xpath("//resource/file")[i].attributes['shelve'].should be nil
463
+ expect(xml.xpath("//resource/file")[i].attributes['size']).to be nil
464
+ expect(xml.xpath("//resource/file")[i].attributes['mimetype']).to be nil
465
+ expect(xml.xpath("//resource/file")[i].attributes['publish']).to be nil
466
+ expect(xml.xpath("//resource/file")[i].attributes['preserve']).to be nil
467
+ expect(xml.xpath("//resource/file")[i].attributes['shelve']).to be nil
468
468
  end
469
- xml.xpath("//resource")[0].attributes['type'].value.should == "image"
470
- xml.xpath("//resource")[1].attributes['type'].value.should == "image"
469
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("image")
470
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("image")
471
471
  end
472
472
 
473
473
  it "should generate valid content metadata with no exif but with user supplied checksums for two tifs of style=simple_book" do
@@ -478,88 +478,88 @@ describe Assembly::ContentMetadata do
478
478
  obj2.provider_md5='qwerty'
479
479
  objects=[obj1,obj2]
480
480
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:style=>:simple_book,:objects=>objects)
481
- result.class.should be String
481
+ expect(result.class).to be String
482
482
  xml = Nokogiri::XML(result)
483
- xml.errors.size.should be 0
484
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "book"
485
- xml.xpath("//resource").length.should be 2
486
- xml.xpath("//resource/file").length.should be 2
487
- xml.xpath("//resource/file/checksum").length.should be 3
488
- xml.xpath("//label").length.should be 2
489
- xml.xpath("//label")[0].text.should =~ /Page 1/
490
- xml.xpath("//label")[1].text.should =~ /Page 2/
491
- xml.xpath("//resource/file/imageData").length.should be 0
492
- xml.xpath("//resource/file/checksum")[0].text.should == "abcdefgh"
493
- xml.xpath("//resource/file/checksum")[1].text.should == "123456789"
494
- xml.xpath("//resource/file/checksum")[2].text.should == "qwerty"
483
+ expect(xml.errors.size).to be 0
484
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("book")
485
+ expect(xml.xpath("//resource").length).to be 2
486
+ expect(xml.xpath("//resource/file").length).to be 2
487
+ expect(xml.xpath("//resource/file/checksum").length).to be 3
488
+ expect(xml.xpath("//label").length).to be 2
489
+ expect(xml.xpath("//label")[0].text).to match(/Page 1/)
490
+ expect(xml.xpath("//label")[1].text).to match(/Page 2/)
491
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
492
+ expect(xml.xpath("//resource/file/checksum")[0].text).to eq("abcdefgh")
493
+ expect(xml.xpath("//resource/file/checksum")[1].text).to eq("123456789")
494
+ expect(xml.xpath("//resource/file/checksum")[2].text).to eq("qwerty")
495
495
  for i in 0..1 do
496
- xml.xpath("//resource/file")[i].attributes['size'].should be nil
497
- xml.xpath("//resource/file")[i].attributes['mimetype'].should be nil
498
- xml.xpath("//resource/file")[i].attributes['publish'].should be nil
499
- xml.xpath("//resource/file")[i].attributes['preserve'].should be nil
500
- xml.xpath("//resource/file")[i].attributes['shelve'].should be nil
496
+ expect(xml.xpath("//resource/file")[i].attributes['size']).to be nil
497
+ expect(xml.xpath("//resource/file")[i].attributes['mimetype']).to be nil
498
+ expect(xml.xpath("//resource/file")[i].attributes['publish']).to be nil
499
+ expect(xml.xpath("//resource/file")[i].attributes['preserve']).to be nil
500
+ expect(xml.xpath("//resource/file")[i].attributes['shelve']).to be nil
501
501
  end
502
- xml.xpath("//resource")[0].attributes['type'].value.should == "page"
503
- xml.xpath("//resource")[1].attributes['type'].value.should == "page"
502
+ expect(xml.xpath("//resource")[0].attributes['type'].value).to eq("page")
503
+ expect(xml.xpath("//resource")[1].attributes['type'].value).to eq("page")
504
504
  end
505
505
 
506
506
  it "should not generate valid content metadata if not all input files exist" do
507
- File.exists?(TEST_TIF_INPUT_FILE).should be true
507
+ expect(File.exists?(TEST_TIF_INPUT_FILE)).to be true
508
508
  junk_file='/tmp/flim_flam_floom.jp2'
509
- File.exists?(junk_file).should be false
509
+ expect(File.exists?(junk_file)).to be false
510
510
  objects=[Assembly::ObjectFile.new(TEST_TIF_INPUT_FILE),Assembly::ObjectFile.new(junk_file)]
511
- lambda {Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:objects=>objects)}.should raise_error
511
+ expect {Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:objects=>objects)}.to raise_error(RuntimeError,"File '#{junk_file}' not found")
512
512
  end
513
513
 
514
514
  it "should generate valid content metadata for images and associated text files, of style=simple_image using bundle=prebundled, and no exif data" do
515
515
  files=[[TEST_RES1_TIF1,TEST_RES1_JP1,TEST_RES1_TIF2,TEST_RES1_JP2,TEST_RES1_TEI,TEST_RES1_TEXT,TEST_RES1_PDF],[TEST_RES2_TIF1,TEST_RES2_JP1,TEST_RES2_TIF2,TEST_RES2_JP2,TEST_RES2_TEI,TEST_RES2_TEXT],[TEST_RES3_TIF1,TEST_RES3_JP1,TEST_RES3_TEI]]
516
516
  objects=files.collect {|resource| resource.collect {|file| Assembly::ObjectFile.new(file)} }
517
517
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:prebundled,:style=>:simple_image,:objects=>objects)
518
- result.class.should be String
518
+ expect(result.class).to be String
519
519
  xml = Nokogiri::XML(result)
520
- xml.errors.size.should be 0
521
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "image"
522
- xml.xpath("//resource").length.should be 3
523
- xml.xpath("//resource/file").length.should be 16
524
- xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value.should == 'res1_image1.tif'
525
- xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value.should == 'res1_image1.jp2'
526
- xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value.should == 'res1_image2.tif'
527
- xml.xpath("//resource[@sequence='1']/file")[3].attributes['id'].value.should == 'res1_image2.jp2'
528
- xml.xpath("//resource[@sequence='1']/file")[4].attributes['id'].value.should == 'res1_teifile.txt'
529
- xml.xpath("//resource[@sequence='1']/file")[5].attributes['id'].value.should == 'res1_textfile.txt'
530
- xml.xpath("//resource[@sequence='1']/file")[6].attributes['id'].value.should == 'res1_transcript.pdf'
531
- xml.xpath("//resource[@sequence='1']/file").length.should be 7
520
+ expect(xml.errors.size).to be 0
521
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("image")
522
+ expect(xml.xpath("//resource").length).to be 3
523
+ expect(xml.xpath("//resource/file").length).to be 16
524
+ expect(xml.xpath("//resource[@sequence='1']/file")[0].attributes['id'].value).to eq('res1_image1.tif')
525
+ expect(xml.xpath("//resource[@sequence='1']/file")[1].attributes['id'].value).to eq('res1_image1.jp2')
526
+ expect(xml.xpath("//resource[@sequence='1']/file")[2].attributes['id'].value).to eq('res1_image2.tif')
527
+ expect(xml.xpath("//resource[@sequence='1']/file")[3].attributes['id'].value).to eq('res1_image2.jp2')
528
+ expect(xml.xpath("//resource[@sequence='1']/file")[4].attributes['id'].value).to eq('res1_teifile.txt')
529
+ expect(xml.xpath("//resource[@sequence='1']/file")[5].attributes['id'].value).to eq('res1_textfile.txt')
530
+ expect(xml.xpath("//resource[@sequence='1']/file")[6].attributes['id'].value).to eq('res1_transcript.pdf')
531
+ expect(xml.xpath("//resource[@sequence='1']/file").length).to be 7
532
532
 
533
- xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value.should == 'res2_image1.tif'
534
- xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value.should == 'res2_image1.jp2'
535
- xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value.should == 'res2_image2.tif'
536
- xml.xpath("//resource[@sequence='2']/file")[3].attributes['id'].value.should == 'res2_image2.jp2'
537
- xml.xpath("//resource[@sequence='2']/file")[4].attributes['id'].value.should == 'res2_teifile.txt'
538
- xml.xpath("//resource[@sequence='2']/file")[5].attributes['id'].value.should == 'res2_textfile.txt'
539
- xml.xpath("//resource[@sequence='2']/file").length.should be 6
533
+ expect(xml.xpath("//resource[@sequence='2']/file")[0].attributes['id'].value).to eq('res2_image1.tif')
534
+ expect(xml.xpath("//resource[@sequence='2']/file")[1].attributes['id'].value).to eq('res2_image1.jp2')
535
+ expect(xml.xpath("//resource[@sequence='2']/file")[2].attributes['id'].value).to eq('res2_image2.tif')
536
+ expect(xml.xpath("//resource[@sequence='2']/file")[3].attributes['id'].value).to eq('res2_image2.jp2')
537
+ expect(xml.xpath("//resource[@sequence='2']/file")[4].attributes['id'].value).to eq('res2_teifile.txt')
538
+ expect(xml.xpath("//resource[@sequence='2']/file")[5].attributes['id'].value).to eq('res2_textfile.txt')
539
+ expect(xml.xpath("//resource[@sequence='2']/file").length).to be 6
540
540
 
541
- xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value.should == 'res3_image1.tif'
542
- xml.xpath("//resource[@sequence='3']/file")[1].attributes['id'].value.should == 'res3_image1.jp2'
543
- xml.xpath("//resource[@sequence='3']/file")[2].attributes['id'].value.should == 'res3_teifile.txt'
544
- xml.xpath("//resource[@sequence='3']/file").length.should be 3
541
+ expect(xml.xpath("//resource[@sequence='3']/file")[0].attributes['id'].value).to eq('res3_image1.tif')
542
+ expect(xml.xpath("//resource[@sequence='3']/file")[1].attributes['id'].value).to eq('res3_image1.jp2')
543
+ expect(xml.xpath("//resource[@sequence='3']/file")[2].attributes['id'].value).to eq('res3_teifile.txt')
544
+ expect(xml.xpath("//resource[@sequence='3']/file").length).to be 3
545
545
 
546
- xml.xpath("//label").length.should be 3
547
- xml.xpath("//resource/file/imageData").length.should be 0
546
+ expect(xml.xpath("//label").length).to be 3
547
+ expect(xml.xpath("//resource/file/imageData").length).to be 0
548
548
  for i in 0..2 do
549
- xml.xpath("//label")[i].text.should == "Image #{i+1}"
550
- xml.xpath("//resource")[i].attributes['type'].value.should == "image"
549
+ expect(xml.xpath("//label")[i].text).to eq("Image #{i+1}")
550
+ expect(xml.xpath("//resource")[i].attributes['type'].value).to eq("image")
551
551
  end
552
552
  end
553
553
 
554
554
  it "should generate content metadata even when no objects are passed in" do
555
555
  objects=[]
556
556
  result = Assembly::ContentMetadata.create_content_metadata(:druid=>TEST_DRUID,:bundle=>:prebundled,:style=>:file,:objects=>objects)
557
- result.class.should be String
557
+ expect(result.class).to be String
558
558
  xml = Nokogiri::XML(result)
559
- xml.errors.size.should be 0
560
- xml.xpath("//contentMetadata")[0].attributes['type'].value.should == "file"
561
- xml.xpath("//resource").length.should be 0
562
- xml.xpath("//resource/file").length.should be 0
559
+ expect(xml.errors.size).to be 0
560
+ expect(xml.xpath("//contentMetadata")[0].attributes['type'].value).to eq("file")
561
+ expect(xml.xpath("//resource").length).to be 0
562
+ expect(xml.xpath("//resource/file").length).to be 0
563
563
  end
564
564
 
565
565
  end