【发布时间】:2014-09-09 12:03:57
【问题描述】:
所以我有一个未定义的方法错误,它适用于 Rspec 方法“to”。我有以下代码的规范
it "sends an email to users who have favorited the post" do
@user.favorites.where(post: @post).create
allow ( FavoriteMailer )
.to receive(:new_comment)
.with(@user, @post, @comment)
.and_return( double(deliver: true))
当我运行规范时,我收到以下错误:
1) Comment after_create with users permission sends an email to users who have favorited the post
Failure/Error: allow ( FavoriteMailer )
NoMethodError:
undefined method `to' for FavoriteMailer:Class
# ./spec/models/comment_spec.rb:18:in `block (4 levels) in <top (required)>'
任何想法为什么会发生这种情况?
【问题讨论】:
标签: ruby-on-rails rspec rspec-rails