Sha256: abdd7778ff603cb0632f21dc620b2bf22788c5107c73151d4b14aee7c12df71c

Contents?: true

Size: 1.69 KB

Versions: 52

Compression:

Stored size: 1.69 KB

Contents

# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes.rb', __FILE__)

describe "String#downcase" do
  it "returns a copy of self with all uppercase letters downcased" do
    "hELLO".downcase.should == "hello"
    "hello".downcase.should == "hello"
  end

  it "is locale insensitive (only replaces A-Z)" do
    "ÄÖÜ".downcase.should == "ÄÖÜ"

    str = Array.new(256) { |c| c.chr }.join
    expected = Array.new(256) do |i|
      c = i.chr
      c.between?("A", "Z") ? c.downcase : c
    end.join

    str.downcase.should == expected
  end

  it "taints result when self is tainted" do
    "".taint.downcase.tainted?.should == true
    "x".taint.downcase.tainted?.should == true
    "X".taint.downcase.tainted?.should == true
  end

  it "returns a subclass instance for subclasses" do
    StringSpecs::MyString.new("FOObar").downcase.should be_kind_of(StringSpecs::MyString)
  end
end

describe "String#downcase!" do
  it "modifies self in place" do
    a = "HeLlO"
    a.downcase!.should equal(a)
    a.should == "hello"
  end

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

  ruby_version_is ""..."1.9" do
    it "raises a TypeError when self is frozen" do
      lambda { "HeLlo".freeze.downcase! }.should raise_error(TypeError)
      lambda { "hello".freeze.downcase! }.should raise_error(TypeError)
    end
  end

  ruby_version_is "1.9" do
    it "raises a RuntimeError when self is frozen" do
      lambda { "HeLlo".freeze.downcase! }.should raise_error(RuntimeError)
      lambda { "hello".freeze.downcase! }.should raise_error(RuntimeError)
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

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