2

我正在为我的 Rails 应用程序编写电子邮件测试,但我不知道如何测试图像是否已正确包含在电子邮件中。我已经尝试过 has_content 和 have_tag,并且到处都用 Google 搜索过,但似乎找不到合适的方法。

必须有一些直接的方法来测试它,除非我遗漏了一些东西。

这是我目前所拥有的......

describe "registration email" do
  it "has the right logo image" do
    email.body.should have_tag("img[src='www.mysite.com/assets/logo.png']")
  end
end

但收到此错误:

NoMethodError:
   undefined method `has_tag?' for :Mail::Body
4

0 回答 0