spec/rews/util_spec.rb in rews-0.2.7 vs spec/rews/util_spec.rb in rews-0.2.9

- old
+ new

@@ -34,20 +34,39 @@ mock(response).to_hash{response_hash} response end end - it "should raise if there are any errors" do + it "should raise a Rews::Error if there are any errors" do client = Object.new lambda { Util.with_error_check(client, :foo, :bar) do response_hash = {:foo=>{:bar=>{:response_class=>"Error", :message_text=>"boo"}}} response = Object.new mock(response).to_hash{response_hash} response end - }.should raise_error + }.should raise_error(Rews::Error) end + + it "should tag any unexpected exceptions with the savon response" do + client = Object.new + exception = RuntimeError.new("boo") + mock(client).log.mock!.warn(exception) + + savon_response = Object.new + + lambda { + Util.with_error_check(client, :foo, :bar) do + mock(savon_response).to_hash{raise exception} + savon_response + end + }.should raise_error{|error| + error.respond_to?(:savon_response).should == true + error.savon_response.should == savon_response + } + end + end describe "single_error_check" do it "should return an error description of the response_class is Error" do client = Object.new