Sha256: 03d21c257db16db860b790ea0f546166b3cd5a6821262e0158354c175ded9f9c

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 KB

Contents

require "spec_helper"

describe String do

  describe "self.random" do
    it "returns a random 100-character String" do
      String.random.should be_a(String)
      String.random.length.should == 100
    end

    it "returns a random String of a given length" do
      String.random(50).should be_a(String)
      String.random(50).length.should == 50
    end
  end

  describe "snakecase" do
    it "converts a lowerCamelCase String to snakecase" do
      "lowerCamelCase".snakecase.should == "lower_camel_case"
    end

    it "converts period characters to underscores" do
      "User.GetEmail".snakecase.should == "user_get_email"
    end
  end

  describe "lower_camelcase" do
    it "converts a snakecase String to lowerCamelCase" do
      "lower_camel_case".lower_camelcase.should == "lowerCamelCase"
    end
  end

  describe "strip_namespace" do
    it "strips the namespace from a namespaced String" do
      "ns:customer".strip_namespace.should == "customer"
    end

    it "returns the original String for a String without namespace" do
      "customer".strip_namespace.should == "customer"
    end
  end

  describe "map_soap_response" do
    it "returns a DateTime Object for Strings matching the xs:dateTime format" do
      "2012-03-22T16:22:33".map_soap_response.should ==
        DateTime.new(2012, 03, 22, 16, 22, 33)
    end

    it "returns true for Strings matching 'true'" do
      "true".map_soap_response.should be_true
    end

    it "returns false for Strings matching 'false'" do
      "false".map_soap_response.should be_false
    end

    it "defaults to return the original value" do
      "whatever".map_soap_response.should == "whatever"
    end
  end

  describe "to_soap_value" do
    it "calls to_s, bypassing Rails to_datetime extension for Strings" do
      "string".to_soap_value.should == "string".to_s
    end
  end

end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
savon-xaop-0.7.2.7 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.6 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.5 spec/savon/core_ext/string_spec.rb
johnreitano-savon-0.7.2.1 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.4 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.3 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.2 spec/savon/core_ext/string_spec.rb
savon-xaop-0.7.2.1 spec/savon/core_ext/string_spec.rb
savon-0.7.4 spec/savon/core_ext/string_spec.rb
savon-0.7.3 spec/savon/core_ext/string_spec.rb
savon-0.7.2 spec/savon/core_ext/string_spec.rb
savon-0.7.1 spec/savon/core_ext/string_spec.rb
savon-0.7.0 spec/savon/core_ext/string_spec.rb
julianmorrison-savon-0.6.8 spec/savon/core_ext/string_spec.rb