class PryTest::Test

Superclass for all test classes. @example Create a subclass with a test.

class SimpleTest < PryTest::Test
  test "common sense" do
    assert 1 > 0
  end
end

Public Class Methods

after(what = nil, &block) click to toggle source

Defines a teardown method that will run after each individual test. @param [Symbol] what Deprecated but maintained for backwards compatibility. @yield A block of code that will serve as the teardown method.

# File lib/pry-test/test.rb, line 40
def after(what = nil, &block)
  @after = block
end
before(what = nil, &block) click to toggle source

Defines a setup method that will run before each individual test. @param [Symbol] what Deprecated but maintained for backwards compatibility. @yield A block of code that will serve as the setup method.

# File lib/pry-test/test.rb, line 33
def before(what = nil, &block)
  @before = block
end
inherited(subclass) click to toggle source

A callback provided by Ruby that is invoked whenever a subclass is created.

# File lib/pry-test/test.rb, line 26
def inherited(subclass)
  subclasses << subclass
end
subclasses() click to toggle source

All subclasses of this class. @return [Array<PryTest::Test>]

# File lib/pry-test/test.rb, line 15
def subclasses
  @subclasses ||= []
end
test(desc, &block) click to toggle source

Defines a test. Allows subclasses to define tests in their class definition.

@param [String] desc A description for the test. @yield A block that defines the test code.

@example

class SimpleTest < PryTest::Test
  test "common sense" do
    assert 1 > 0
  end
end
# File lib/pry-test/test.rb, line 56
def test(desc, &block)
  wrapper = PryTest::TestWrapper.new(self, desc, &block)
  wrapper.create_method(:before, &@before) if @before
  wrapper.create_method(:after, &@after) if @after
  tests << wrapper
end
tests() click to toggle source

All individual tests defined in this class. @return [Array<PryTest::TestWrapper>]

# File lib/pry-test/test.rb, line 21
def tests
  @tests ||= []
end