【问题标题】:How to use the Pending module in ActiveSupport如何在 ActiveSupport 中使用 Pending 模块
【发布时间】:2023-03-05 16:54:01
【问题描述】:

我似乎无法使 ActiveSupport::Testing 中的 Pending 模块工作。

test/unit/pending.rb 包含:

require 'test_helper'
require 'active_support/testing/pending'

class PendingTest < ActiveSupport::TestCase
  include ActiveSupport::Testing::Pending

  pending "a pending case with a closure" do
     assert false
  end
end

但是当我执行 ruby​​ unit/foo.rb 时,我得到:

undefined method `pending' for PendingTest:Class (NoMethodError)

我查看了 ActiveSupport gem 中的 pending.rb 中的代码。挂起的方法在一个 除非定义?(规范) 块,但我验证了 Spec 没有定义。

提前谢谢...

【问题讨论】:

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


    【解决方案1】:

    pending 方法需要在测试内部调用,而不是在类上调用:

    test "it works" do
      pending "well, it will eventually"
    end
    

    【讨论】:

    • 酷,谢谢。我认为pending 方法将块作为参数这一事实误导了我。因此,您仍然可以将测试主体包含在待处理的块中。似乎块内的所有断言都需要失败,这是我没想到的......
    猜你喜欢
    • 2011-09-05
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 2012-10-18
    • 1970-01-01
    • 2013-11-02
    • 1970-01-01
    相关资源
    最近更新 更多