Sha256: f84febc083def2f122db9824691ca6c296c31efe7c6b8756c558e74c87d55503

Contents?: true

Size: 429 Bytes

Versions: 1

Compression:

Stored size: 429 Bytes

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe Array do

  it "should be able to invert an array" do
    [:a, :b, :c].invert.should eql({:a => 0, :b => 1, :c => 2})
  end
  
  it "should be able to invert an array with an optional block" do
    keys = [4,5,6]
    array = [:a, :b, :c]
    inverted = array.invert do |x, i|
      keys[i]
    end
    inverted.should eql({:a => 4, :b => 5, :c => 6})
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fathom-0.5.0 spec/fathom/ext/array_spec.rb