在我的测试中,Rpec,我有这个
before { @user = create(:user) }
let(:mail) { SignUpMailer.message(@user) }
然后我收到错误:
Failure/Error: @mail = SignUpMailer.message(@user) }
ArgumentError:
wrong number of arguments (0 for 1)
我也尝试过:
before { @user = create(:user)
@mail = SignUpMailer.message(@user) }
但它仍然说上面的错误。有什么想法吗?
修改 邮件代码
class SignUpMailer < ActionMailer::Base
default from: "Assign It App <support@assignitapp.com>"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.sign_up_mailer.message.subject
#
def message(user)
@sign_in_url = sign_in_url
@user_name = user.name
mail subject: "Welcome to Assign It App"
mail to: user.email
end
end
另一项尝试:
before { @user = create(:user) }
let(:mail) { SignUpMailer.message([@user]) }
哪个给我
Failure/Error: let(:mail) { SignUpMailer.message([@user]) }
NoMethodError:
undefined method `name' for #<Array:0xa0c9860>
所以邮件确实接受了争论。