Sha256: a5eee432bcc766d1c78c7293d3dad2c282f679de5de0d67edd36c93c15248681

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

require 'spec_helper'
require 'gorillib/array/hashify'

describe Array, :simple_spec, :only do

  describe '#hashify' do
    it 'returns a hash pairing elements with value from block' do
      [1,2,3].hashify{|x| x * x }.should == { 1 => 1, 2 => 4, 3 => 9 }
      [1,2,3].hashify{|x| x > 2 ? nil : x }.should == { 1 => 1, 2 => 2, 3 => nil }
    end
    it "returns an empty hash on an empty array" do
      [].hashify{}.should == {}
    end
    it "fails if no block given" do
      expect{ [1,2,3].hashify }.to raise_error(ArgumentError)
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gorillib-0.6.0 spec/gorillib/array/hashify_spec.rb
gorillib-0.5.2 spec/gorillib/array/hashify_spec.rb
gorillib-0.5.0 spec/gorillib/array/hashify_spec.rb