Module: Testify::Runner::ClassMethods

Defined in:
lib/runner.rb

Instance Method Summary collapse

Instance Method Details

#framework(fw = nil) ⇒ Object

Defines and/or returns the framework to use. This can be any class whose instances are Testify apps, and an instance of this class will be placed at the bottom of the Testify stack used by Runner#run. Typically, this will probably be a test framework built on Testify or (more likely, at least for now) a Testify adaptor for some existing framework. If the class descends from Testify::Framework::Base and defines an alias (eg, aka :rspec), you may use that alias instead of passing in the actual class.

Example:

class YourRunner < Testify::Runner::Base
  framework :rspec
end
@runner = YourRunner.new
@runner.framework         # <= Testify::Framework::RspecAdaptor

Note that you can also specify the framework on an instance, using #framework=.

@runner = Testify::Runner.new
@runner.framework YourAwesomeTestifyFrameworkClass


117
118
119
120
# File 'lib/runner.rb', line 117

def framework( fw = nil )
  self.framework = Testify::Framework.find(fw) if fw
  self.send(:class_variable_get, :@@framework)
end

#middleware(*middlewares) ⇒ Object

Defines and/or returns the middleware to use, in the same manner as .framework. Note that this completely replaces any previous middleware specified for this class.

Example:

class YourRunner < Testify::Runner::Base
  middleware :dots, :colorize
end


132
133
134
135
# File 'lib/runner.rb', line 132

def middleware( *middlewares )
  self.middleware = middlewares.map { |mw| Testify::Middleware.find(mw) } unless middlewares.empty?
  self.send(:class_variable_get, :@@middleware)
end