Cześć,
Jak wg Was najlepiej, najładniej i najbardziej Rails Way wykonać poniższy test?
title = Nokogiri::HTML(page.body).css(".title").map(&:text)
title.should == ["TITILE:", "TTITLE2", "TITLE3"]
EDIT:
Może tak?
page.has_css?(".title", :count => 3).should be_true
page.should have_css(".title", :content => ["TITILE:", "TTITLE2", "TITLE3"])
W drugim tescie przechodzi każdy test nawet jeżeli w :content wpisze błędne dane.
["TITILE:", "TTITLE2", "TITLE3"].each do |title|
page.should have_css('.title', content: title)
end
have_css chyba nie przyjmuje arraya jako argument dla content. znaczy przyjmuje, ale nie robi z tym tego czego byś oczekiwał
describe “New ad specs” do
before(:all) do @ads = []
3.times{ @ads << Ad.sham!(:email_id => 1, :verification_date => Time.now) }
end
describe “aa” do
it “listing all ads”, :focus do
visit ads_path
page.has_selector?(".title", :text => “Lista ogłoszeń”).should be_true
page.has_selector?(".ad", :count => 3).should be_true @ads.each do |ad|
page.should have_css(".ad", :text => ad.title )
end
end
end
end[/code]