Sha256: 707737c7392aa5025dbc5de5e30acfacf68afc19470f8ab9a23bd23cd506e907

Contents?: true

Size: 1.64 KB

Versions: 98

Compression:

Stored size: 1.64 KB

Contents

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

describe "String#rstrip" do
  it "returns a copy of self with trailing whitespace removed" do
   "  hello  ".rstrip.should == "  hello"
   "  hello world  ".rstrip.should == "  hello world"
   "  hello world \n\r\t\n\r".rstrip.should == "  hello world"
   "hello".rstrip.should == "hello"
   "hello".rstrip.should == "hello"
  end

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

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

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

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

    #  lambda { "  hello  ".freeze.rstrip! }.should raise_error(TypeError)
    #end
  #end
  
  #ruby_version_is "1.9" do
   # ruby_bug "[ruby-core:23666]", "1.9.2" do
     # it "raises a RuntimeError if self is frozen" do
     #   lambda { "hello".freeze.rstrip!     }.should raise_error(RuntimeError)
     #   lambda { "".freeze.rstrip!          }.should raise_error(RuntimeError)
     #   lambda { "  hello  ".freeze.rstrip! }.should raise_error(RuntimeError)
     # end
    #end
  #end  
end

Version data entries

98 entries across 98 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-7.5.1 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-7.4.1 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-7.1.17 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-6.2.0 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-6.0.11 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.18 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.17 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.15 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.0.22 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.2 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.0.7 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.0.3 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-5.5.0 spec/phone_spec/app/spec/string/rstrip_spec.rb
tauplatform-1.0.3 spec/phone_spec/app/spec/string/rstrip_spec.rb
tauplatform-1.0.2 spec/phone_spec/app/spec/string/rstrip_spec.rb
tauplatform-1.0.1 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-3.5.1.12 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-3.3.5 spec/phone_spec/app/spec/string/rstrip_spec.rb
rhodes-3.4.2 spec/phone_spec/app/spec/string/rstrip_spec.rb