Class: Specifier::Example
- Inherits:
-
Object
- Object
- Specifier::Example
- Defined in:
- lib/specifier/example.rb
Overview
Configures an example (used for it statements).
Usage:
example = Specifier::Example.new("...") do
expect(value).to equal(value)
end
world = Specifier::World.new
example.run(world)
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
Instance Method Summary collapse
-
#initialize(description, &block) ⇒ Example
constructor
A new instance of Example.
- #run(world) ⇒ Object
Constructor Details
#initialize(description, &block) ⇒ Example
Returns a new instance of Example.
19 20 21 22 |
# File 'lib/specifier/example.rb', line 19 def initialize(description, &block) @description = description @block = block end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/specifier/example.rb', line 17 def description @description end |
Instance Method Details
#run(world) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/specifier/example.rb', line 24 def run(world) world.instance_eval(&@block) Result.new(:pass) rescue StandardError => Result.new(:fail, ) end |