<commit_before>require "spec_helper"

describe Savon::SOAP do
  before { @soap = new_soap_instance }

  def new_soap_instance(options = {})
    Savon::SOAP.new UserFixture.soap_actions[:find_user], { :id => 666 },
      options, UserFixture.namespace_uri
  end

  describe "SOAPNamespace" do
    it "contains the SOAP namespace for each supported SOAP version" do
      Savon::Validation::SOAPVersions.each do |soap_version|
        Savon::SOAP::SOAPNamespace[soap_version].should_not be_nil
      end
    end
  end

  describe "ContentType" do
    it "contains the Content-Types for each supported SOAP version" do
      Savon::Validation::SOAPVersions.each do |soap_version|
        Savon::SOAP::ContentType[soap_version].should_not be_nil
      end
    end
  end

  describe "initialize" do
    it "expects the SOAP action, body, options and the namespace URI" do
      new_soap_instance
    end
  end

  describe "action" do
    it "returns the SOAP action" do
      @soap.action.should == UserFixture.soap_actions[:find_user]
    end
  end

  describe "options" do
    it "returns the SOAP options" do
      @soap.options.should == {}
    end
  end

  describe "body" do
    before { Savon::SOAP.version = 1 }

    it "returns the XML for a SOAP request" do
      @soap.body.should == soap_body
    end

    it "caches the XML, returning the same Object every time" do
      @soap.body.object_id.should == @soap.body.object_id
    end

    it "uses the SOAP namespace for the SOAP version passed in via options" do
      soap = new_soap_instance :soap_version => 2
      soap.body.should include Savon::SOAP::SOAPNamespace[2]
    end

    it "uses the SOAP namespace for the default SOAP version otherwise" do
      Savon::SOAP.version = 2
      @soap.body.should include Savon::SOAP::SOAPNamespace[2]
    end

    def soap_body
      "<env:Envelope xmlns:wsdl=\"http://v1_0.ws.user.example.com\" " <<
        "xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" <<
        "<env:Header></env:Header>" <<
        "<env:Body><wsdl:findUser><id>666</id></wsdl:findUser></env:Body>" <<
      "</env:Envelope>"
    end
  end

  describe "version" do
    it "returns the SOAP version from options" do
      soap = new_soap_instance :soap_version => 2
      soap.version.should == 2
    end

    it "returns the default SOAP version otherwise" do
      @soap.version.should == Savon::SOAP.version
    end
  end

end
<commit_msg>test for non-empty strings<commit_after>require "spec_helper"

describe Savon::SOAP do
  before { @soap = new_soap_instance }

  def new_soap_instance(options = {})
    Savon::SOAP.new UserFixture.soap_actions[:find_user], { :id => 666 },
      options, UserFixture.namespace_uri
  end

  describe "SOAPNamespace" do
    it "contains the SOAP namespace for each supported SOAP version" do
      Savon::Validation::SOAPVersions.each do |soap_version|
        Savon::SOAP::SOAPNamespace[soap_version].should be_a String
        Savon::SOAP::SOAPNamespace[soap_version].should_not be_empty
      end
    end
  end

  describe "ContentType" do
    it "contains the Content-Types for each supported SOAP version" do
      Savon::Validation::SOAPVersions.each do |soap_version|
        Savon::SOAP::ContentType[soap_version].should be_a String
        Savon::SOAP::ContentType[soap_version].should_not be_empty
      end
    end
  end

  describe "initialize" do
    it "expects the SOAP action, body, options and the namespace URI" do
      new_soap_instance
    end
  end

  describe "action" do
    it "returns the SOAP action" do
      @soap.action.should == UserFixture.soap_actions[:find_user]
    end
  end

  describe "options" do
    it "returns the SOAP options" do
      @soap.options.should == {}
    end
  end

  describe "body" do
    before { Savon::SOAP.version = 1 }

    it "returns the XML for a SOAP request" do
      @soap.body.should == soap_body
    end

    it "caches the XML, returning the same Object every time" do
      @soap.body.object_id.should == @soap.body.object_id
    end

    it "uses the SOAP namespace for the SOAP version passed in via options" do
      soap = new_soap_instance :soap_version => 2
      soap.body.should include Savon::SOAP::SOAPNamespace[2]
    end

    it "uses the SOAP namespace for the default SOAP version otherwise" do
      Savon::SOAP.version = 2
      @soap.body.should include Savon::SOAP::SOAPNamespace[2]
    end

    def soap_body
      "<env:Envelope xmlns:wsdl=\"http://v1_0.ws.user.example.com\" " <<
        "xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" <<
        "<env:Header></env:Header>" <<
        "<env:Body><wsdl:findUser><id>666</id></wsdl:findUser></env:Body>" <<
      "</env:Envelope>"
    end
  end

  describe "version" do
    it "returns the SOAP version from options" do
      soap = new_soap_instance :soap_version => 2
      soap.version.should == 2
    end

    it "returns the default SOAP version otherwise" do
      @soap.version.should == Savon::SOAP.version
    end
  end

end

{'fraction_non_alphanumeric': 0.10464420968706398, 'fraction_numerical': 0.005979669124975085, 'mean_word_length': 3.050040355125101, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1425009', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1576, 'n_words': 441}