Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic spec for MediaFile class
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<MediaFile> | ||
<MediaFileTypeCode>04</MediaFileTypeCode> | ||
<MediaFileLinkTypeCode>01</MediaFileLinkTypeCode> | ||
<MediaFileLink>http://www.allenandunwin.com/BookCovers/resized_9788888028729_224_297_FitSquare.jpg</MediaFileLink> | ||
</MediaFile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# coding: utf-8 | ||
|
||
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') | ||
|
||
require 'onix' | ||
|
||
context "ONIX::MediaFile" do | ||
|
||
before(:each) do | ||
data_path = File.join(File.dirname(__FILE__),"..","data") | ||
file1 = File.join(data_path, "media_file.xml") | ||
@doc = LibXML::XML::Document.file(file1) | ||
@root = @doc.root | ||
end | ||
|
||
specify "should correctly convert to a string" do | ||
mf = ONIX::MediaFile.from_xml(@root.to_s) | ||
mf.to_xml.to_s[0,11].should eql("<MediaFile>") | ||
end | ||
|
||
specify "should provide read access to first level attibutes" do | ||
mf = ONIX::MediaFile.from_xml(@root.to_s) | ||
mf.media_file_type_code.should eql(4) | ||
mf.media_file_link_type_code.should eql(1) | ||
mf.media_file_link.should eql("http://www.allenandunwin.com/BookCovers/resized_9788888028729_224_297_FitSquare.jpg") | ||
end | ||
|
||
specify "should provide write access to first level attibutes" do | ||
mf = ONIX::MediaFile.new | ||
|
||
mf.media_file_type_code = 2 | ||
mf.to_xml.to_s.include?("<MediaFileTypeCode>02</MediaFileTypeCode>").should be_true | ||
|
||
mf.media_file_link_type_code = 1 | ||
mf.to_xml.to_s.include?("<MediaFileLinkTypeCode>01</MediaFileLinkTypeCode>").should be_true | ||
|
||
mf.media_file_link = "http://www.google.com" | ||
mf.to_xml.to_s.include?("<MediaFileLink>http://www.google.com</MediaFileLink>").should be_true | ||
end | ||
|
||
end | ||
|