The HTML page is supposed to have the following code:
<div class="user-image" style="background-image:url(/images/user_image.jpg)">
How can you test this with Capybara and RSpec?
Presumably, you are trying to verify that this div is using the specified background image. I would probably do something like this:
it "has a user image" do page.should have_selector('div.user-image') end it "displays the user image" do page.find('div.user-image')['style'].should == 'background-image:url(/images/user_image.jpg)' end
Capybara and Selenium let you run javascript in a browser and return a result
here's how:
page.execute_script 'return $("div.user-image").css("background-image");'