Sha256: b73b22619b84767beab00a0c9d70755ef7c243ee2d93e7fd82b720b187649b55

Contents?: true

Size: 787 Bytes

Versions: 83

Compression:

Stored size: 787 Bytes

Contents

describe :array_indexes, :shared => true do
  it "returns elements at integer argument indexes (DEPRECATED)" do
    array = [1, 2, 3, 4, 5]

    x = mock('4')
    def x.to_int() 4 end

    params = [1, 0, 5, -1, -8, 10, x]
    array.send(@method, *params).should == array.values_at(*params)
  end
  
  it "tries to convert the passed arguments to Integers using #to_int" do
    obj = mock('to_int')
    obj.should_receive(:to_int).and_return(1, 3)
    [1, 2, 3, 4, 5].send(@method, obj, obj).should == [2, 4]
  end

  it "returns elements in range arguments as nested arrays (DEPRECATED)" do
    array = [1, 2, 3, 4, 5]
    params = [0..2, 1...3, 4..6]
    array.indexes(*params).should == [[1, 2, 3], [2, 3], [5]]
    array.indices(*params).should == [[1, 2, 3], [2, 3], [5]]
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/array/shared/indexes.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/array/shared/indexes.rb