SusSourceSusShared

module Shared

Represents a shared test context that can be reused across multiple test files.

Definitions

attr_accessor :name

Signature

attribute String

The name of the shared context.

attr_accessor :block

Signature

attribute Proc

The block containing the shared test code.

def self.build(name, block)

Build a new Shared context.

Signature

parameter name String

The name of the shared context.

parameter block Proc

The block containing the shared test code.

returns Module

A new Shared module.

Implementation

def self.build(name, block)
	base = Module.new
	base.extend(Shared)
	base.name = name
	base.block = block
	
	return base
end

def included(base)

Called when this module is included in a test class.

Signature

parameter base Class

The class including this module.

Implementation

def included(base)
	base.class_exec(&self.block)
end

def prepended(base)

Called when this module is prepended to a test class.

Signature

parameter base Class

The class prepending this module.

Implementation

def prepended(base)
	base.class_exec(&self.block)
end