File: frequencies_spec.rb

package info (click to toggle)
ruby-powerpack 0.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 53
  • sloc: ruby: 727; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'spec_helper'

describe 'Enumerable#frequencies' do
  context 'empty collection' do
    it 'evaluates to an empty hash' do
      expect([].frequencies).to eql({})
    end
  end

  context 'populated collection' do
    it 'counts the number of ocurrences and returns a hash in the form value => count' do
      expect([1, 1, :symbol, 3, 1, :symbol, 'string'].frequencies).to eql(
        1        => 3,
        3        => 1,
        'string' => 1,
        :symbol  => 2
      )
    end
  end
end