File: string_builder_spec.rb

package info (click to toggle)
ruby-ice-cube 0.16.4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 800 kB
  • sloc: ruby: 7,823; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require File.dirname(__FILE__) + '/../spec_helper'

describe IceCube::StringBuilder do

  describe :sentence do

    it 'should return empty string when none' do
      expect(IceCube::StringBuilder.sentence([])).to eq('')
    end

    it 'should return sole when one' do
      expect(IceCube::StringBuilder.sentence(['1'])).to eq('1')
    end

    it 'should split on and when two' do
      expect(IceCube::StringBuilder.sentence(['1', '2'])).to eq('1 and 2')
    end

    it 'should comma and when more than two' do
      expect(IceCube::StringBuilder.sentence(['1', '2', '3'])).to eq('1, 2, and 3')
    end

  end

end