Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking existence of images and favicons with RSpec and Capybara

Is there a good way to check on existence of images and favicons using rspec and capybara?

I can check on the DOM of favicons and images, but I want to be able to check that those images load as well. Is this possible with rspec and capybara?

like image 899
Jason Kim Avatar asked Mar 23 '13 04:03

Jason Kim


1 Answers

describe "check images and favicon" do
  before { visit "url/to/check")

  it "should have the images" do
    page.should have_css('img', text: "image1.jpg")

  it "should have the favicon" do
    page.should have_xpath("/html/head/link[@href='favicon.ico']"
  end 
end
like image 150
Billy Chan Avatar answered Sep 23 '22 08:09

Billy Chan