Sha256: 77bd4f727eed4b46fc15a510d9c85835e52314a9e9160066e4e0b03e8207f677
Contents?: true
Size: 1.3 KB
Versions: 7
Compression:
Stored size: 1.3 KB
Contents
require "spec_helper" RSpec.describe Element do html <<-HTML <table class="players"> <tr class="player"> <td class="name">mario</td> <td class="surname">rossi</td> </tr> <tr class="player"> <td class="name">paolo</td> <td class="surname">bianchi</td> </tr> </table> HTML describe '#each' do it "should change all td to pippa" do Element.find('table.players td').each do |el| el.html = "pippa" end Element.find('table.players td').first.html.should == 'pippa' end end describe '#map' do it "should change all td.surname as array of stirng" do lst = Element.find('table.players td.surname').map {|el| el.html } lst.should == ['rossi','bianchi'] end end describe "#to_a" do it "should return a list of class Array" do Element.find('table.players td.surname').to_a.class.should == Array end it "should check first and last element" do Element.find('table.players td.surname').to_a.first.html == "rossi" Element.find('table.players td.surname').to_a.last.html == "bianchi" end it "should get only element with class surname" do Element.find('table.players td').to_a.select {|el| el.has_class?('surname') }. map {|el| el.class }.uniq == ['surname'] end end end
Version data entries
7 entries across 7 versions & 1 rubygems