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 an empty SOAP envelope with a SOAP 1.1 envelope namespace" do
ApricotEatsGorilla.soap_envelope.should ==
'' <<
''
end
it "returns a SOAP envelope with a custom namespace and body content" do
ApricotEatsGorilla.soap_envelope(:wsdl => "http://example.com") do
"123"
end.should == '' <<
'123'
end
it "does not change an already defined SOAP envelope namespace" do
ApricotEatsGorilla.soap_envelope(:env => "http://example.com").should ==
'' <<
''
end
it "sets the SOAP envelope namespace for SOAP version 1.2 if requested" do
ApricotEatsGorilla.soap_envelope({}, 2).should ==
'' <<
''
end
it "does not set a SOAP envelope namespace in case of an invalid SOAP version" do
ApricotEatsGorilla.soap_envelope({}, 123).should ==
''
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