Sha256: a12c560d9e9973cd7f16d95aca3020404629b106f908127bc8e7f026be240b1d

Contents?: true

Size: 692 Bytes

Versions: 6

Compression:

Stored size: 692 Bytes

Contents

# unicode: utf-8
# frozen_string_literals: true

RSpec.describe Strings, '#fold' do
  {
    "  \n"      => '  ',
    "\n  "      => '  ',
    "\n"        => ' ',
    "\n\n\n"    => ' ',
    " \n "      => '  ',
    " \n \n \n" => '   '
  }.each do |actual, expected|
    it "removes newline '#{actual.gsub(/\n/, '\\n')}' to '#{expected}'" do
      expect(Strings::Fold.fold(actual)).to eq(expected)
    end
  end

  {
    "  \r\n" => '  ',
    "\r\n  " => '  ',
    "\r\n"   => ' ',
    " \r\n " => '  ',
  }.each do |actual, expected|
    it "squashes '#{actual.gsub(/\r\n/, '\\r\\n')}' to '#{expected}'" do
      expect(Strings::Fold.fold(actual, "\r\n")).to eq(expected)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
strings-0.1.8 spec/unit/fold/fold_spec.rb
strings-0.1.7 spec/unit/fold/fold_spec.rb
strings-0.1.6 spec/unit/fold/fold_spec.rb
strings-0.1.5 spec/unit/fold/fold_spec.rb
strings-0.1.4 spec/unit/fold/fold_spec.rb
strings-0.1.3 spec/unit/fold/fold_spec.rb