Rspec Mail对象不响应包含?

时间:2015-02-08 04:36:44

标签: ruby-on-rails rspec

我正试图在screencast的帮助下学习rails中的测试。但是我坚持这一步

expect(last_email).to include(user.email)

错误消息是

expected #<Mail::Message:47172420, Multipart: true, Headers: <Date: Sun, 08 Feb 2015 09:51:56 +0530>, <From: from@example.com>, <To: person1@example.com>, <Message-ID: <54d6e464682e_1450a1b32815670@User-PC.mail>>, <Subject: Password Reset>, <Mime-Version: 1.0>, <Content-Type: multipart/alternative; boundary="--==_mimepart_54d6e4642e9e_1450a1b328155a"; charset=UTF-8>, <Content-Transfer-Encoding: 7bit>> to include "person1@example.com", but it does not respond to `include?`  

邮件对象不响应'include?'。这可能是由于rspec语法的变化或者代码有问题。谢谢你的答案。

1 个答案:

答案 0 :(得分:1)

您似乎未在to上致电last_email

expect(last_email.to).to include(user.email)