require 'spec_helper'
module GutenbergRdf
class Rdf
describe Media do
let(:xml) do
'
293684
text/plain; charset=utf-8
2010-02-16T08:29:52.373092
'
end
let(:media) { Media.new(REXML::Document.new(xml).elements['rdf:RDF/pgterms:file']) }
it "expects the file URI" do
expect(media.uri).to eql 'http://www.gutenberg.org/ebooks/98765.txt.utf-8'
end
it "expects the file media type" do
expect(media.media_type).to eql 'text/plain'
end
it "expects the file encoding" do
expect(media.encoding).to eql 'utf-8'
end
it "expects modified to be a DateTime" do
expect(media.modified.class).to be DateTime
end
it "should return the modified datetime" do
expect(media.modified.to_s).to eql '2010-02-16T08:29:52-07:00'
end
context "when there are two media types" do
let(:xml) do
'
116685
application/zip
text/plain; charset=us-ascii
2006-09-28T12:37:26
'
end
let(:media) { Media.new(REXML::Document.new(xml).elements['rdf:RDF/pgterms:file']) }
it "expects the first entry to be used" do
expect(media.media_type).to eql 'application/zip'
end
it "expects the encoding to be an empty string" do
expect(media.encoding).to eql ''
end
end
end
end
end