Sha256: e69188251a77187a20368de1428fd6dd9c378cb71f8e128f7839c095be1842d3

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'
require 'cape/util'

describe Cape::Util do
  describe '.pluralize' do
    it "should pluralize 'foo' as expected" do
      Cape::Util.pluralize('foo').should == 'foos'
    end

    it "should pluralize 'foo' as expected for a count of 2" do
      Cape::Util.pluralize('foo', 2).should == 'foos'
    end

    it "should not pluralize 'foo' for a count of 1" do
      Cape::Util.pluralize('foo', 1).should == 'foo'
    end

    it "should pluralize 'foo' as expected for a count of 0" do
      Cape::Util.pluralize('foo', 0).should == 'foos'
    end

    it "should pluralize 'foo' as expected for a count of -1" do
      Cape::Util.pluralize('foo', -1).should == 'foos'
    end
  end

  describe '.to_list_phrase' do
    it 'should make the expected list phrase of an empty array' do
      Cape::Util.to_list_phrase([]).should == ''
    end

    it 'should make the expected list phrase of a 1-element array' do
      Cape::Util.to_list_phrase(%w(foo)).should == 'foo'
    end

    it 'should make the expected list phrase of a 2-element array' do
      Cape::Util.to_list_phrase(%w(foo bar)).should == 'foo and bar'
    end

    it 'should make the expected list phrase of a 3-element array' do
      array = %w(foo bar baz)
      Cape::Util.to_list_phrase(array).should == 'foo, bar, and baz'
    end
  end
end 

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cape-1.7.0 spec/cape/util_spec.rb
cape-1.6.2 spec/cape/util_spec.rb
cape-1.6.1 spec/cape/util_spec.rb