【问题标题】:Undefined method 'assert_select_email' in ActionMailer tests [Rails 3.2.13]ActionMailer 测试中未定义的方法“assert_select_email”[Rails 3.2.13]
【发布时间】:2014-03-18 05:24:37
【问题描述】:

我在邮件测试中尝试使用 assert_select_email 时遇到以下错误:

undefined method `assert_select_email' for ...

TestClass 继承自 < ActionMailer::TestCase 和 'assert_equal' 等其他断言也有效。

如此处所述:

http://apidock.com/rails/ActionDispatch/Assertions/SelectorAssertions/assert_select_email

我设置

 ActionMailer::Base.perform_deliveries = true

有什么想法吗? 哦,我正在使用

  • Rails 3.2.13

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 testing actionmailer


    【解决方案1】:

    看起来是因为它不在ActionMailer::TestCase

    你想要assert_emails吗?

    【讨论】:

      【解决方案2】:

      您可能可以在测试类中包含ActionDispatch::Assertions::SelectorAssertions。像这样:

      UserMailerTest < ActionMailer::TestCase
        include ActionController::Assertions::SelectorAssertions
      
        # …
      end
      

      那么你应该可以使用assert_select_email

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-02-16
        • 1970-01-01
        • 1970-01-01
        • 2023-03-20
        • 2013-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多