如何在ActiveSupport中使用Pending模块

mmi*_*dol 2 testing activesupport ruby-on-rails-3

我似乎无法使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
Run Code Online (Sandbox Code Playgroud)

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

undefined method `pending' for PendingTest:Class (NoMethodError)
Run Code Online (Sandbox Code Playgroud)

我查看了ActiveSupport gem中pending.rb中的代码.挂起的方法在除非定义的?(Spec)块之内,但我确认未定义Spec.

提前致谢...

Rya*_*igg 9

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

test "it works" do
  pending "well, it will eventually"
end
Run Code Online (Sandbox Code Playgroud)

  • 很酷,谢谢.我认为由于`pending`方法将块作为参数这一事实我误导了.因此,您仍然可以将测试主体包含在挂起块中.看起来块内的所有断言都是*必需*失败,我不会期望... (2认同)