Sha256: ad0f677a5d767f620ff976321287a4b91434d94d2dfa4a0efb4653b8e231ee29

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper")

describe ApricotEatsGorilla do
  include SpecHelper

  # setup
  describe "setup" do
    it "yields self to a given block" do
      ApricotEatsGorilla.setup do |yielded|
        yielded.should == ApricotEatsGorilla
      end
    end
  end

  # soap_envelope
  describe "soap_envelope" do
    before { ApricotEatsGorilla.sort_keys = true }

    it "returns a SOAP envelope with an empty-element body tag" do
      ApricotEatsGorilla.soap_envelope.should ==
        '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">' <<
        '<env:Body /></env:Envelope>'
    end
    
    it "returns a SOAP envelope with a custom namespace and body content" do
      result = ApricotEatsGorilla.soap_envelope(:wsdl => "http://example.com") do
        "<id>123</id>"
      end
      result.should == '<env:Envelope' <<
        ' xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"' <<
        ' xmlns:wsdl="http://example.com">' <<
        '<env:Body><id>123</id></env:Body></env:Envelope>'
    end
  end

  # []
  describe "[]" do
    before { reset_library_options }

    it "converts a given XML into a Hash" do
      xml = "<root><name>Jungle Julia</name></root>"
      ApricotEatsGorilla[xml].should == { :name => "Jungle Julia" }
    end

    it "converts a given XML with a custom root node into a Hash" do
      xml = "<root><something><name>Jungle Julia</name></something></root>"
      ApricotEatsGorilla[xml, "//something"].should == { :name => "Jungle Julia" }
    end

    it "converts a given Hash into XML" do
      hash = { "apricot" => "eats gorilla" }
      ApricotEatsGorilla[hash] == "<apricot>eats gorilla</apricot>"
    end
  end

end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rubiii-apricoteatsgorilla-0.5.2 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
rubiii-apricoteatsgorilla-0.5.3 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
rubiii-apricoteatsgorilla-0.5.4 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
rubiii-apricoteatsgorilla-0.5.5 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
smacks-apricoteatsgorilla-0.5.1 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
smacks-apricoteatsgorilla-0.5.2 spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb