diff --git a/lib/avm/xmp.rb b/lib/avm/xmp.rb index 533356a..62045f6 100644 --- a/lib/avm/xmp.rb +++ b/lib/avm/xmp.rb @@ -24,6 +24,9 @@ module AVM def initialize(doc = nil) @doc = doc || empty_xml_doc + + raise StandardError.new('not a Nokogiri node') if !@doc.kind_of?(::Nokogiri::XML::Node) + ensure_namespaces! ensure_descriptions_findable! end diff --git a/spec/avm/xmp_spec.rb b/spec/avm/xmp_spec.rb index b062122..dd02a8b 100644 --- a/spec/avm/xmp_spec.rb +++ b/spec/avm/xmp_spec.rb @@ -6,6 +6,14 @@ describe AVM::XMP do 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 before { xmp.get_refs do |refs|