我有一个带有自定义视图助手的模块。实际上它使用了link_to helper的修改代码。只需将查询字符串附加到生成的链接即可。我现有的测试失败,因为无法找到自定义帮助程序。我如何包含它以便RSpec可用?我尝试了以下方法:
1.使用包括:
describe MyClass do
include MyHelper
2.使用配置
RSpec.configure do |config|
config.include MyHelper
end
3.在spec_helper.rb中添加
config.include MyHelper
这是错误:
1) Mailer#calendar_item_notification should send email for task
Failure/Error: expect {Mailer.calendar_item_notification('User', @user.id).deliver}.to change { ActionMailer::Base.deliveries.count }.by(1)
ActionView::Template::Error:
undefined method `<<' for #<Proc:0x00000013102d28>
# ./app/helpers/mailer_helper.rb:88:in `link_username'
# ./app/views/user_mailer/calendar_item_notification.html.erb:137:in `_app_views_user_mailer_calendar_item_notification_html_erb___206027131771876632_159436760'
# ./app/mailers/user_mailer.rb:136:in `calendar_item_notification'
# ./spec/mailers/user_mailer_spec.rb:19:in `block (4 levels) in <top (required)>'
# ./spec/mailers/user_mailer_spec.rb:19:in `block (3 levels) in <top (required)>'
# ./spec/support/misc.rb:13:in `block in suppress_output'
# ./spec/support/misc.rb:12:in `tap'
# ./spec/support/misc.rb:12:in `suppress_output'
# -e:1:in `<main>'
由于