Sha256: e40de23a8e464b6335b655910aaf6acc65203a7a4a6fdecdb7dbbc8d36e24997
Contents?: true
Size: 765 Bytes
Versions: 7
Compression:
Stored size: 765 Bytes
Contents
require "spec_helper" RSpec.describe "Element#at" do html <<-HTML <div class="foo" id="blah"></div> <div class="foo" id="bleh"></div> <div class="foo" id="bluh"></div> HTML it "returns the element at the given index" do foos = Element.find '.foo' foos.length.should == 3 foos.at(0).id.should == "blah" foos.at(1).id.should == "bleh" foos.at(2).id.should == "bluh" end it "counts from the last index for negative values" do foos = Element.find '.foo' foos.at(-1).id.should == "bluh" foos.at(-2).id.should == "bleh" foos.at(-3).id.should == "blah" end it "returns nil for indexes outside range" do foos = Element.find '.foo' foos.at(-4).should == nil foos.at(4).should == nil end end
Version data entries
7 entries across 7 versions & 1 rubygems