require File.join(File.dirname(__FILE__), "..", "spec_helper") describe ApricotEatsGorilla do include SpecHelper # setup describe "setup" do it "yields self to a given block" do ApricotEatsGorilla.setup do |yielded| yielded.should == ApricotEatsGorilla end end end # soap_envelope describe "soap_envelope" do before { ApricotEatsGorilla.sort_keys = true } it "returns a SOAP envelope with an empty-element body tag" do ApricotEatsGorilla.soap_envelope.should == '' << '' end it "returns a SOAP envelope with a custom namespace and body content" do result = ApricotEatsGorilla.soap_envelope(:wsdl => "http://example.com") do "123" end result.should == '' << '123' end end # [] describe "[]" do before { reset_library_options } it "converts a given XML into a Hash" do xml = "Jungle Julia" ApricotEatsGorilla[xml].should == { :name => "Jungle Julia" } end it "converts a given XML with a custom root node into a Hash" do xml = "Jungle Julia" ApricotEatsGorilla[xml, "//something"].should == { :name => "Jungle Julia" } end it "converts a given Hash into XML" do hash = { "apricot" => "eats gorilla" } ApricotEatsGorilla[hash] == "eats gorilla" end end end