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
nameString The name of the shared context.
-
parameter
blockProc 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
baseClass 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
baseClass The class prepending this module.
Implementation
def prepended(base)
base.class_exec(&self.block)
end