Skip to content

Commit

Permalink
added builder#pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
rubiii committed Mar 7, 2013
1 parent 2589047 commit 259e04a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/savon/builder.rb
@@ -1,5 +1,6 @@
require "savon/header"
require "savon/message"
require "nokogiri"
require "builder"
require "gyoku"

Expand Down Expand Up @@ -27,6 +28,10 @@ def initialize(operation_name, wsdl, globals, locals)
@used_namespaces = convert_type_namespaces_to_hash
end

def pretty
Nokogiri.XML(to_s).to_xml(:indent => 2)
end

def to_s
return @locals[:xml] if @locals.include? :xml

Expand Down
6 changes: 6 additions & 0 deletions spec/savon/builder_spec.rb
Expand Up @@ -9,6 +9,12 @@
let(:wsdl) { Wasabi::Document.new Fixture.wsdl(:authentication) }
let(:no_wsdl) { Wasabi::Document.new }

describe "#pretty" do
it "returns the pretty printed request" do
expect(builder.pretty).to include("<env:Body>\n <tns:authenticate/>")
end
end

describe "#to_s" do
it "includes the global :env_namespace if it's available" do
globals[:env_namespace] = :soapenv
Expand Down

0 comments on commit 259e04a

Please sign in to comment.