Sha256: 433ca0ade036591a7cb2062796c94ba146a11db5382a941400576c314aefd908
Contents?: true
Size: 948 Bytes
Versions: 9
Compression:
Stored size: 948 Bytes
Contents
require 'spec_helper' describe Capybara::Result do let :string do Capybara.string <<-STRING <ul> <li>Alpha</li> <li>Beta</li> <li>Gamma</li> <li>Delta</li> </ul> STRING end let :result do string.all '//li' end it "has a length" do result.length.should == 4 end it "has a first element" do result.first.text == 'Alpha' end it "has a last element" do result.last.text == 'Delta' end it "can return an element by its index" do result.at(1).text.should == 'Beta' result[2].text.should == 'Gamma' end it "can be mapped" do result.map(&:text).should == %w(Alpha Beta Gamma Delta) end it "can be selected" do result.select do |element| element.text.include? 't' end.length.should == 2 end it "can be reduced" do result.reduce('') do |memo, element| memo += element.text[0] end.should == 'ABGD' end end
Version data entries
9 entries across 9 versions & 2 rubygems