Module: Sus::Shared
- Defined in:
- lib/sus/shared.rb
Overview
Represents a shared test context that can be reused across multiple test files.
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#name ⇒ Object
Returns the value of attribute name.
- #The block containing the shared test code.(blockcontainingthesharedtestcode.) ⇒ Object readonly
- #The name of the shared context.(nameofthesharedcontext.) ⇒ Object readonly
Class Method Summary collapse
-
.build(name, block) ⇒ Object
Build a new Shared context.
Instance Method Summary collapse
-
#included(base) ⇒ Object
Called when this module is included in a test class.
-
#prepended(base) ⇒ Object
Called when this module is prepended to a test class.
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
15 16 17 |
# File 'lib/sus/shared.rb', line 15 def block @block end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/sus/shared.rb', line 12 def name @name end |
#The block containing the shared test code.(blockcontainingthesharedtestcode.) ⇒ Object (readonly)
15 |
# File 'lib/sus/shared.rb', line 15 attr_accessor :block |
#The name of the shared context.(nameofthesharedcontext.) ⇒ Object (readonly)
12 |
# File 'lib/sus/shared.rb', line 12 attr_accessor :name |
Class Method Details
.build(name, block) ⇒ Object
Build a new Shared context.
21 22 23 24 25 26 27 28 |
# File 'lib/sus/shared.rb', line 21 def self.build(name, block) base = Module.new base.extend(Shared) base.name = name base.block = block return base end |
Instance Method Details
#included(base) ⇒ Object
Called when this module is included in a test class.
32 33 34 |
# File 'lib/sus/shared.rb', line 32 def included(base) base.class_exec(&self.block) end |
#prepended(base) ⇒ Object
Called when this module is prepended to a test class.
38 39 40 |
# File 'lib/sus/shared.rb', line 38 def prepended(base) base.class_exec(&self.block) end |