Sha256: 541067e38ed59e0357b9ba1e37022d3600feb6eb746833a552ef2ed2506e81c4

Contents?: true

Size: 524 Bytes

Versions: 9

Compression:

Stored size: 524 Bytes

Contents

require 'spec_helper'
require 'ronin/extensions/enumerable'

describe Enumerable do
  describe "#map_hash" do
    it "should map elements to a Hash" do
      [1, 2, 3].map_hash { |i| i ** 2 }.should == {
        1 => 1,
        2 => 4,
        3 => 9
      }
    end

    it "should not map the same element twice" do
      [1, 2, 2].map_hash { |i| rand }.keys.should =~ [1, 2]
    end

    it "should set the default_proc of the Hash" do
      hash = [].map_hash { |i| i ** 2 }

      hash[3].should == 9
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ronin-support-0.5.1 spec/extensions/enumerable_spec.rb
ronin-support-0.5.0 spec/extensions/enumerable_spec.rb
ronin-support-0.5.0.rc2 spec/extensions/enumerable_spec.rb
ronin-support-0.5.0.rc1 spec/extensions/enumerable_spec.rb
ronin-support-0.4.1 spec/extensions/enumerable_spec.rb
ronin-support-0.4.0 spec/extensions/enumerable_spec.rb
ronin-support-0.4.0.rc2 spec/extensions/enumerable_spec.rb
ronin-support-0.4.0.rc1 spec/extensions/enumerable_spec.rb
ronin-support-0.3.0 spec/extensions/enumerable_spec.rb