Class: Spectre::EvaluationContext
- Includes:
- Delegate
- Defined in:
- lib/spectre.rb
Overview
This context will be created by assert and expect methods. Failures are reported here.
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
:stopdoc:.
-
#failures ⇒ Object
readonly
:stopdoc:.
Instance Method Summary collapse
-
#initialize(engine, desc) ⇒ EvaluationContext
constructor
A new instance of EvaluationContext.
-
#report(failure) ⇒ Object
Report a failure within the
EvaluationContext.
Methods included from Delegate
#instance_eval, #instance_exec, #method_missing, #respond_to_missing?
Constructor Details
#initialize(engine, desc) ⇒ EvaluationContext
Returns a new instance of EvaluationContext.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/spectre.rb', line 155 def initialize(engine, desc, &) @desc = desc @failures = [] engine.formatter.log(:info, desc) do instance_eval(&) if @failures.any? engine.logger.error("#{desc} - failed") [:error, :failed, nil] else engine.logger.info("#{desc} - ok") [:info, :ok, nil] end rescue Failure => e engine.logger.error("#{e.} - failed") @failures << e [:error, :failed, nil] end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spectre::Delegate