Sha256: 4d45b4ed485c35bbff15601af533997b828340a333bb00c98800b0030a9c3b9e

Contents?: true

Size: 1.58 KB

Versions: 98

Compression:

Stored size: 1.58 KB

Contents

#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
#require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'

describe "String#strip" do
  it "returns a new string with leading and trailing whitespace removed" do
    "   hello   ".strip.should == "hello"
    "   hello world   ".strip.should == "hello world"
    "\tgoodbye\r\n".strip.should == "goodbye"
    "  goodbye \000".strip.should == "goodbye"
  end

  #it "taints the result when self is tainted" do
  #  "".taint.strip.tainted?.should == true
  #  "ok".taint.strip.tainted?.should == true
  #  "  ok  ".taint.strip.tainted?.should == true
  #end
end

describe "String#strip!" do
  it "modifies self in place and returns self" do
    a = "   hello   "
    a.strip!.should == a
    a.should == "hello"
  end

  it "returns nil if no modifications where made" do
    a = "hello"
    a.strip!.should == nil
    a.should == "hello"
  end

  #ruby_version_is ""..."1.9" do
  #  it "raises a TypeError if self is frozen" do
  #    "hello".freeze.strip! # ok, nothing changed
  #    "".freeze.strip! # ok, nothing changed

  #    lambda { "  hello  ".freeze.strip! }.should raise_error(TypeError)
  #  end
  #end

  #ruby_version_is "1.9" do
   # ruby_bug "#1552", "1.9.2" do
   #   it "raises a RuntimeError if self is frozen" do
   #     lambda {"hello".freeze.strip!      }.should raise_error(RuntimeError)
   #     lambda {"".freeze.strip!           }.should raise_error(RuntimeError)
   #     lambda { "  hello  ".freeze.strip! }.should raise_error(RuntimeError)
   #   end
    #end
  #end
end

Version data entries

98 entries across 98 versions & 2 rubygems

Version Path
rhodes-3.2.2 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.2.beta spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.1 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.9 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.8 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.7 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.6 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.5 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.4 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.2 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.2.0.beta.1 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.1 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.1.beta spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0.beta.5 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0.beta.4 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0.beta.3 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0.beta.2 spec/phone_spec/app/spec/string/strip_spec.rb
rhodes-3.1.0.beta.1 spec/phone_spec/app/spec/string/strip_spec.rb