Class: Test::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/pending.rb

Instance Method Summary collapse

Instance Method Details

#pending(description = "", &block) ⇒ Object

The pending method lets you define a block of test code that is currently "pending" functionality.

You can use it two ways. One is simply put a string as the parameter:

def test_web_service_integration
pending "This is not done yet..."
end

This will output a "P" in the test output alerting there is pending functionality.

You can also supply a block of code:

def test_new_helpers
pending "New helpers for database display" do
  output = render_record(User.first)
  assert_equal "Jerry User ([email protected])", output
end
end

If the block doesn't fail, then the test will flunk with output like:

<New helpers for database display> did not fail.

If the test fails (i.e., the functionality isn't implemented), then it will not fail the surrounding test.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/pending.rb', line 31

def pending(description = "", &block)
  if block_given?
    failed = false

    begin
      block.call
    rescue
      failed = true
    end

    flunk("<#{description}> did not fail.") unless failed 
  end
  
  print "P"
end