spec/rews/util_spec.rb in rews-0.2.12 vs spec/rews/util_spec.rb in rews-0.5.0
- old
+ new
@@ -23,10 +23,19 @@
Util.camel_keys(:foo_bar=>1, "bar_baz"=>2, "bam"=>3).should ==
{"FooBar"=>1, "BarBaz"=>2, "Bam"=>3}
end
end
+ describe "rsxml_to_xml" do
+ it "should camelize tags and attribute names, and prefix tags with t:" do
+ Util.rsxml_to_xml([:foo]).should == "<t:Foo></t:Foo>"
+ Util.rsxml_to_xml([:foo_foo, {:bar_bar=>"blah"}]).should == '<t:FooFoo BarBar="blah"></t:FooFoo>'
+ Util.rsxml_to_xml([:foo_foo, {:bar_bar=>"blah"}, "foofoo", [:baz_baz, {:boo_hoo=>"10"}, "bazbaz"]]).should ==
+ '<t:FooFoo BarBar="blah">foofoo<t:BazBaz BooHoo="10">bazbaz</t:BazBaz></t:FooFoo>'
+ end
+ end
+
describe "with_error_check" do
it "should yield, convert the response to a hash and fetch_in the status" do
client = Object.new
Util.with_error_check(client, :foo, :bar) do
response_hash = {:foo=>{:bar=>{:response_class=>"Success"}}}
@@ -49,11 +58,11 @@
end
it "should log any unexpected exceptions and tag with the savon response" do
client = Object.new
exception = RuntimeError.new("boo")
- mock(client).log do |block|
+ mock(Rews).log do |block|
logger = Object.new
mock(logger).warn(exception)
block.call(logger)
end
@@ -80,10 +89,10 @@
end
it "should log a warning and return if the response_class is Warning" do
client = Object.new
status = {:response_class=>"Warning", :message_text=>"boo", :response_code=>"BooWarning"}
- mock(client).log() do |p|
+ mock(Rews).log() do |p|
logger = Object.new
mock(logger).warn("BooWarning - boo")
p.call(logger)
end
Util.single_error_check(client, status).should == nil