Skip to content
Browse files

added operation#build

accepts the same local options and/or an optional block
as operation#call, but returns the builder. allows to
inspect the request xml without sending an actual request.
  • Loading branch information...
1 parent 259e04a commit 39e5adb75cf9d9717b025c3d04fecf740bd6c123 @rubiii rubiii committed Mar 6, 2013
Showing with 15 additions and 2 deletions.
  1. +5 −2 lib/savon/operation.rb
  2. +10 −0 spec/savon/operation_spec.rb
View
7 lib/savon/operation.rb
@@ -37,10 +37,13 @@ def initialize(name, wsdl, globals)
@globals = globals
end
- def call(locals = {}, &block)
+ def build(locals = {}, &block)
set_locals(locals, block)
+ Builder.new(@name, @wsdl, @globals, @locals)
+ end
- builder = Builder.new(@name, @wsdl, @globals, @locals)
+ def call(locals = {}, &block)
+ builder = build(locals, &block)
response = Savon.notify_observers(@name, builder, @globals, @locals)
response ||= call! build_request(builder)
View
10 spec/savon/operation_spec.rb
@@ -53,6 +53,16 @@ def new_operation(operation_name, wsdl, globals)
end
end
+ describe "#build" do
+ it "returns the Builder" do
+ operation = new_operation(:verify_address, wsdl, globals)
+ builder = operation.build(message: { test: 'message' })
+
+ expect(builder).to be_a(Savon::Builder)
+ expect(builder.to_s).to include('<tns:VerifyAddress><tns:test>message</tns:test></tns:VerifyAddress>')
+ end
+ end
+
describe "#call" do
it "returns a response object" do
operation = new_operation(:verify_address, wsdl, globals)

0 comments on commit 39e5adb

Please sign in to comment.
Something went wrong with that request. Please try again.