Class: PryTest::Test
- Inherits:
-
Object
- Object
- PryTest::Test
- Defined in:
- lib/pry-test/test.rb
Overview
Superclass for all test classes.
Class Method Summary collapse
-
.after(what = nil) { ... } ⇒ Object
Defines a teardown method that will run after each individual test.
-
.before(what = nil) { ... } ⇒ Object
Defines a setup method that will run before each individual test.
-
.inherited(subclass) ⇒ Object
A callback provided by Ruby that is invoked whenever a subclass is created.
-
.subclasses ⇒ Array<PryTest::Test>
All subclasses of this class.
-
.test(desc) { ... } ⇒ Object
Defines a test.
-
.tests ⇒ Array<PryTest::TestWrapper>
All individual tests defined in this class.
Class Method Details
.after(what = nil) { ... } ⇒ Object
Defines a teardown method that will run after each individual test.
40 41 42 |
# File 'lib/pry-test/test.rb', line 40 def after(what=nil, &block) @after = block end |
.before(what = nil) { ... } ⇒ Object
Defines a setup method that will run before each individual test.
33 34 35 |
# File 'lib/pry-test/test.rb', line 33 def before(what=nil, &block) @before = block end |
.inherited(subclass) ⇒ Object
A callback provided by Ruby that is invoked whenever a subclass is created.
26 27 28 |
# File 'lib/pry-test/test.rb', line 26 def inherited(subclass) subclasses << subclass end |
.subclasses ⇒ Array<PryTest::Test>
All subclasses of this class.
15 16 17 |
# File 'lib/pry-test/test.rb', line 15 def subclasses @subclasses ||= [] end |
.test(desc) { ... } ⇒ Object
Defines a test. Allows subclasses to define tests in their class definition.
56 57 58 59 60 61 |
# 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 ⇒ Array<PryTest::TestWrapper>
All individual tests defined in this class.
21 22 23 |
# File 'lib/pry-test/test.rb', line 21 def tests @tests ||= [] end |