Sha256: be412a81f87666d80147452b6a37aa8f12b6046c2db418ec62c9b7ce08487a46
Contents?: true
Size: 1.63 KB
Versions: 6
Compression:
Stored size: 1.63 KB
Contents
require File.instance_eval { expand_path join(dirname(__FILE__), 'test_helper') } require 'freighthopper' class ArrayTest < Test::Unit::TestCase context 'symbols' do should 'map to sym' do assert_equal [:a, :b, :c, :d, :e], %w( a b c d e ).symbols end end context 'exclude' do should 'return false if the array includes the element' do assert_not %w(a b c).exclude?('b') end should 'return true if the array does not include the element' do assert %w(a b c).exclude?('z') end end context 'singular' do should 'return the singular object if there is indeed only one' do assert_singular 5, [5] end should 'return nil if the array is empty' do assert_singular nil, [] end should 'return nil if the array has > 1 item' do assert_singular nil, [1, 2] end end context 'singular questionmark' do should 'return true if the array has only one member' do assert_singular [5] end should 'return false if the array is empty' do assert_not_singular [] end should 'return false if the array has more than one member' do assert_not_singular [1, 2] end end context 'singular bang' do should 'return the item if there is just one' do assert_equal 5, [5].singular! end should 'raise if there are no items' do e = assert_raise(RuntimeError){ [].singular! } assert_message 'not singular', e end should 'raise if there are more than one item' do e = assert_raise(RuntimeError){ [1, 2].singular! } assert_message 'not singular', e end end end
Version data entries
6 entries across 6 versions & 1 rubygems