nokogiri doc check for avm::xmp

This commit is contained in:
John Bintz 2011-03-23 14:40:38 -04:00
parent c4718535ae
commit b703ee1a55
2 changed files with 11 additions and 0 deletions

View File

@ -24,6 +24,9 @@ module AVM
def initialize(doc = nil) def initialize(doc = nil)
@doc = doc || empty_xml_doc @doc = doc || empty_xml_doc
raise StandardError.new('not a Nokogiri node') if !@doc.kind_of?(::Nokogiri::XML::Node)
ensure_namespaces! ensure_namespaces!
ensure_descriptions_findable! ensure_descriptions_findable!
end end

View File

@ -6,6 +6,14 @@ describe AVM::XMP do
subject { xmp } subject { xmp }
describe '#initialize' do
context 'not a nokogiri document' do
let(:xmp) { self.class.describes.new("definitely not nokogiri node") }
it { expect { xmp }.to raise_error(StandardError, /not a Nokogiri node/) }
end
end
describe '#get_refs' do describe '#get_refs' do
before { before {
xmp.get_refs do |refs| xmp.get_refs do |refs|