require "spec_helper"
describe Savon::LogMessage do
it "returns the message if it's not XML" do
message = log_message("hello", [:password], :pretty_print).to_s
expect(message).to eq("hello")
end
it "returns the message if it shouldn't be filtered or pretty printed" do
Nokogiri.expects(:XML).never
message = log_message("", [], false).to_s
expect(message).to eq("")
end
it "pretty prints a given message" do
message = log_message("hello", [], :pretty_print).to_s
expect(message).to include("\n")
expect(message).to include("\n ")
end
it "filters tags in a given message" do
message = log_message("secret", [:password], false).to_s
expect(message).to include("***FILTERED***")
end
it "properly applies Proc filter" do
filter = Proc.new do |document|
document.xpath('//password').each do |node|
node.content = "FILTERED"
end
end
message = log_message("secret", [filter], false).to_s
expect(message).to include("FILTERED")
end
def log_message(*args)
Savon::LogMessage.new(*args)
end
end