spec/lib/soap_object_spec.rb in soap-object-0.2 vs spec/lib/soap_object_spec.rb in soap-object-0.3

- old
+ new

@@ -12,11 +12,15 @@ basic_auth 'steve', 'secret' digest_auth 'digest', 'auth' log_level :error end +class TestWorld + include SoapObject::Factory +end + describe SoapObject do let(:client) { double('client') } let(:subject) { TestServiceWithWsdl.new } @@ -61,9 +65,31 @@ subject.send(:client_properties)[:digest_auth].should == ['digest', 'auth'] end it "should allow one to set the log level" do subject.send(:client_properties)[:log_level].should == :error + end + end + + context "when using the factory to create to service" do + let(:world) { TestWorld.new } + + it "should create a valid service object" do + service = world.using(TestServiceWithWsdl) + service.should be_instance_of TestServiceWithWsdl + end + + it "should create a valid service and invoke a block" do + world.using(TestServiceWithWsdl) do |service| + service.should be_instance_of TestServiceWithWsdl + end + end + + it "should create the service the first time we use it" do + obj = TestServiceWithWsdl.new + TestServiceWithWsdl.should_receive(:new).once.and_return(obj) + world.using(TestServiceWithWsdl) + world.using(TestServiceWithWsdl) end end context "when calling methods on the service" do before do