Sha256: baab53ab82e063f35ce29b110e477cd6579a33a61fb8c7f25d2b822679f80532

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

modes_expectations = {
  []                                          => [],
  [1]                                         => [1],
  [1.0]                                       => [1.0],
  [1, -1]                                     => [-1, 1],
  [3, 1, 3]                                   => [3],
  [3, 1, 3.0]                                 => [3],
  [3.0, 1, 3]                                 => [3.0],
  (0...0)                                     => [],
  (1..1)                                      => [1],
  (0..3)                                      => [0, 1, 2, 3],
  [BigDecimal("0.0")]                         => [BigDecimal("0.0")],
  [BigDecimal("1.0"), -2, BigDecimal("1.0")]  => [BigDecimal("1.0")],
  [:b, :c, :b, :c, :c, :a]                    => [:c]
}

describe Enumerable do
  describe "#modes" do
    modes_expectations.each do |data, expected|
      it "is #{expected.inspect} for #{data.inspect}" do
        modes = data.modes
        modes.should       == expected
        modes.class.should == expected.class
      end
    end

    it "calls map first if a block is given" do
      f = Struct.new(:x)
      data = [f.new(:a), f.new(:b), f.new(:b)]
      data.modes(&:x).should == [:b]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_stats-1.1.0 spec/enumerable/modes_spec.rb