Sha256: 2ad7336e519d349c513a34e06e7edcae6a571f8e7e876555a7882f85c8ab5ef3

Contents?: true

Size: 643 Bytes

Versions: 4

Compression:

Stored size: 643 Bytes

Contents

RSpec.describe "Hash#transform_string_values" do

  it "should transforms all strings in infinite recursion" do
    hash     = {a: "hey", b: {c: "hi", d: ["ho"]}}
    expected = {a: "HEY", b: {c: "HI", d: ["HO"]}}
    result   = hash.transform_string_values { |str| str.upcase }

    expect(result).to eq expected
  end

end


RSpec.describe "Hash#transform_string_values!" do

  it "should transforms all strings in infinite recursion" do
    hash     = {a: "hey", b: {c: "hi", d: ["ho"]}}
    expected = {a: "HEY", b: {c: "HI", d: ["HO"]}}

    hash.transform_string_values! { |str| str.upcase }
    expect(hash).to eq expected
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eitil-1.2.4 spec/eitil_core/hash/transform_string_values_spec.rb
eitil-1.2.3 spec/eitil_core/hash/transform_string_values_spec.rb
eitil-1.2.2 spec/eitil_core/hash/transform_string_values_spec.rb
eitil-1.2.1 spec/eitil_core/hash/transform_string_values_spec.rb