File: squish_spec.rb

package info (click to toggle)
ruby-powerpack 0.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 492 kB
  • sloc: ruby: 819; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 589 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'spec_helper'

unless String.method_defined? :squish
  describe 'String#squish' do
    it 'strips leading and trailing whitespace' do
      expect(' Peter   '.squish).to eq('Peter')
    end

    it 'compacts internal whitespace' do
      expect("Peter\r\n \t   Parker".squish).to eq('Peter Parker')
    end
  end

  describe 'String#squish!' do
    it 'strips leading and trailing whitespace' do
      expect(' Peter   '.squish!).to eq('Peter')
    end

    it 'compacts internal whitespace' do
      expect("Peter\r\n \t   Parker".squish!).to eq('Peter Parker')
    end
  end
end