1 describe :array_indexes, :shared => true do
2 it "returns elements at integer argument indexes (DEPRECATED)" do
3 array = [1, 2, 3, 4, 5]
8 params = [1, 0, 5, -1, -8, 10, x]
9 array.send(@method, *params).should == array.values_at(*params)
12 it "tries to convert the passed arguments to Integers using #to_int" do
14 obj.should_receive(:to_int).and_return(1, 3)
15 [1, 2, 3, 4, 5].send(@method, obj, obj).should == [2, 4]
18 it "checks whether the passed arguments respond to #to_int" do
19 obj = mock('method_missing to_int')
20 obj.should_receive(:respond_to?).with(:to_int).any_number_of_times.and_return(true)
21 obj.should_receive(:method_missing).with(:to_int).twice.and_return(1, 3)
22 [1, 2, 3, 4, 5].send(@method, obj, obj).should == [2, 4]
25 it "returns elements in range arguments as nested arrays (DEPRECATED)" do
26 array = [1, 2, 3, 4, 5]
27 params = [0..2, 1...3, 4..6]
28 array.indexes(*params).should == [[1, 2, 3], [2, 3], [5]]
29 array.indices(*params).should == [[1, 2, 3], [2, 3], [5]]