Sha256: 585e4cb16a26b773efe0508ca7afaa3f4151851042d262ff63209cceddd2adae

Contents?: true

Size: 1.81 KB

Versions: 4

Compression:

Stored size: 1.81 KB

Contents

#encoding:utf-8

require 'spec_helper'

describe WashOut::Param do

  context "custom types" do

    class Abraka1 < WashOut::Type
      map(
        :test => :string
      )
    end

    class Abraka2 < WashOut::Type
      type_name 'test'
      map :foo => Abraka1
    end

    it "loads custom_types" do
      soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
      map = WashOut::Param.parse_def soap_config, Abraka2

      map.should be_a_kind_of(Array)
      map[0].name.should == 'foo'
      map[0].map[0].name.should == 'test'
    end

    it "respects camelization setting" do
      soap_config = WashOut::SoapConfig.new({ camelize_wsdl: true })

      map = WashOut::Param.parse_def soap_config, Abraka2

      map.should be_a_kind_of(Array)
      map[0].name.should == 'Foo'
      map[0].map[0].name.should == 'Test'
    end
  end

  it "should accept nested empty arrays" do
    soap_config = WashOut::SoapConfig.new({ camelize_wsdl: false })
    map = WashOut::Param.parse_def(soap_config, {:nested => {:some_attr => :string, :empty => [:integer] }} )
    map[0].load( {:nested => nil}, :nested).should == {}
  end

  describe "booleans" do
    let(:soap_config) { WashOut::SoapConfig.new({ camelize_wsdl: false }) }
    # following http://www.w3.org/TR/xmlschema-2/#boolean, only true, false, 0 and 1 are allowed.
    # Nori maps the strings true and false to TrueClass and FalseClass, but not 0 and 1.
    let(:map) { WashOut::Param.parse_def(soap_config, :value => :boolean) }

    it "should accept 'true' and '1'" do
      map[0].load({:value => true}, :value).should be_true
      map[0].load({:value => "1"}, :value).should be_true
    end

    it "should accept 'false' and '0'" do
      map[0].load({:value => false}, :value).should be_false
      map[0].load({:value => "0"}, :value).should be_false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wash_out-0.9.2 spec/lib/wash_out/param_spec.rb
wash_out-0.9.0 spec/lib/wash_out/param_spec.rb
wash_out-0.9.0.beta.2 spec/lib/wash_out/param_spec.rb
wash_out-0.9.0.beta.1 spec/lib/wash_out/param_spec.rb