Template Method
What?
A Template Method is a method defined purely in terms of the methods that it expects a subclass to implement.
Why?
The Template Method Pattern allows a developer to define the overall structure of an operation in a parent class while providing control over the specific implementation to subclasses.
How?
class BaseTest
# This is our template method. We don't necessarily expect set_up, run_test,
# or tear_down to be implemented in the BaseTest class.
def execute
set_up
run_test
tear_down
end
end
class OurTest < BaseTest
def set_up
# our implementation
end
def run_test
# our implementation
end
def tear_down
# our implementation
end
end