From 015d35f5c725a8ee50f7428a1147ffe53e81dd4d Mon Sep 17 00:00:00 2001 From: rubiii Date: Sun, 20 Dec 2009 20:16:05 +0100 Subject: [PATCH] improved specs for disabling the wsdl --- spec/savon/client_spec.rb | 38 ++++++++++++++++++++------------ spec/savon/core_ext/hash_spec.rb | 8 +++---- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/spec/savon/client_spec.rb b/spec/savon/client_spec.rb index 8fc837d2..b70836d3 100644 --- a/spec/savon/client_spec.rb +++ b/spec/savon/client_spec.rb @@ -28,17 +28,6 @@ @client.request.should be_a Savon::Request end - it "has a getter for returning whether to use the Savon::WSDL (global setting)" do - @client.wsdl?.should be_true - - Savon::Client.wsdl = false - @client.wsdl?.should be_false - Savon::Client.wsdl = true - - @client.wsdl = false - @client.wsdl?.should be_false - end - it "responds to SOAP actions while still behaving as usual otherwise" do WSDLFixture.authentication(:operations).keys.each do |soap_action| @client.respond_to?(soap_action).should be_true @@ -52,9 +41,30 @@ @client.authenticate.should be_a Savon::Response end - it "dispatches SOAP calls via method_missing without using WSDL" do - @client.wsdl = false - @client.authenticate.should be_a Savon::Response + describe "disabling retrieving and parsing the WSDL document" do + it "can be done globally for every instance of Savon::Client" do + @client.wsdl?.should be_true + Savon::Client.wsdl = false + + expect_the_wsdl_to_be_disabled + @client.authenticate.should be_a Savon::Response + + Savon::Client.wsdl = true + end + + it "can be done per request" do + @client.wsdl = false + + expect_the_wsdl_to_be_disabled + @client.authenticate.should be_a Savon::Response + end + + def expect_the_wsdl_to_be_disabled + @client.wsdl?.should be_false + [:respond_to?, :operations, :namespace_uri].each do |method| + Savon::WSDL.any_instance.expects(method).never + end + end end it "raises a Savon::SOAPFault in case of a SOAP fault" do diff --git a/spec/savon/core_ext/hash_spec.rb b/spec/savon/core_ext/hash_spec.rb index 0dda21c7..a93b0400 100644 --- a/spec/savon/core_ext/hash_spec.rb +++ b/spec/savon/core_ext/hash_spec.rb @@ -80,11 +80,11 @@ def singleton.to_datetime end it "calls to_s on Strings even if they respond to to_datetime" do - singleton = "gorilla" - singleton.expects( :to_s ).returns singleton - singleton.expects( :to_datetime ).never + object = "gorilla" + object.expects(:to_s).returns object + object.expects(:to_datetime).never - { :name => singleton }.to_soap_xml.should == "gorilla" + { :name => object }.to_soap_xml.should == "gorilla" end it "call to_s on any other Object" do