Sha256: a696343dbbc8a84eeaa2d274651329a5991bbc18847ad74ea13465eb4f3cf91e
Contents?: true
Size: 1.91 KB
Versions: 4
Compression:
Stored size: 1.91 KB
Contents
require File.dirname(__FILE__) + '/../../spec_helper' describe "OEmbed::Formatter::XML::Backends::REXML" do include OEmbedSpecHelper before(:all) do lambda { OEmbed::Formatter::XML.backend = 'REXML' }.should_not raise_error (!!defined?(REXML)).should == true end it "should support XML" do proc { OEmbed::Formatter.supported?(:xml) }. should_not raise_error(OEmbed::FormatNotSupported) end it "should be using the XmlSimple backend" do OEmbed::Formatter::XML.backend.should == OEmbed::Formatter::XML::Backends::REXML end it "should decode an XML String" do decoded = OEmbed::Formatter.decode(:xml, valid_response(:xml)) # We need to compare keys & values separately because we don't expect all # non-string values to be recognized correctly. decoded.keys.should == valid_response(:object).keys decoded.values.map{|v|v.to_s}.should == valid_response(:object).values.map{|v|v.to_s} end it "should raise an OEmbed::ParseError when decoding an invalid XML String" do lambda { decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_container', :xml)) }.should raise_error(OEmbed::ParseError) lambda { decode = OEmbed::Formatter.decode(:xml, invalid_response('unclosed_tag', :xml)) }.should raise_error(OEmbed::ParseError) lambda { decode = OEmbed::Formatter.decode(:xml, invalid_response('invalid_syntax', :xml)) }.should raise_error(OEmbed::ParseError) end it "should raise an OEmbed::ParseError when decoding fails with an unexpected error" do error_to_raise = ArgumentError OEmbed::Formatter::XML.backend.parse_error.should_not be_kind_of(error_to_raise) ::REXML::Document.should_receive(:new). and_raise(error_to_raise.new("unknown error")) lambda { decode = OEmbed::Formatter.decode(:xml, valid_response(:xml)) }.should raise_error(OEmbed::ParseError) end end
Version data entries
4 entries across 4 versions & 1 rubygems