我有一个场景需要验证我刚上传的图片是否存在于下一页。
以下工作得很好,但是我的文件夹结构基于listing_id变量。如何在这里使用正则表达式将image与仅文件名匹配,而不是整个URL?
Then /^I should see the image "(.+)"$/ do |image|
page.should have_xpath("//img[@src=\"/public/images/#{image}\"]")
end
我有一个场景需要验证我刚上传的图片是否存在于下一页。
以下工作得很好,但是我的文件夹结构基于listing_id变量。如何在这里使用正则表达式将image与仅文件名匹配,而不是整个URL?
Then /^I should see the image "(.+)"$/ do |image|
page.should have_xpath("//img[@src=\"/public/images/#{image}\"]")
end
ends-with
函数。 - alpha-mouseends-with
XPath 函数而不是contains
。我对 Ruby 一无所知,但复制粘贴 @dmarkow 的代码将会得到page.should have_xpath("//img[ends-with(@src, \"#{image}\")]")
。 - alpha-mouse