Class: FunctionalLightService::Testing::ContextFactory
- Defined in:
- lib/functional-light-service/testing/context_factory.rb
Instance Attribute Summary collapse
-
#organizer ⇒ Object
readonly
Returns the value of attribute organizer.
Class Method Summary collapse
Instance Method Summary collapse
- #for(action) ⇒ Object
-
#initialize(organizer) ⇒ ContextFactory
constructor
A new instance of ContextFactory.
-
#with ⇒ Object
More than one arguments can be passed to the Organizer's #call method.
Constructor Details
#initialize(organizer) ⇒ ContextFactory
Returns a new instance of ContextFactory.
43 44 45 |
# File 'lib/functional-light-service/testing/context_factory.rb', line 43 def initialize(organizer) @organizer = organizer end |
Instance Attribute Details
#organizer ⇒ Object (readonly)
Returns the value of attribute organizer.
6 7 8 |
# File 'lib/functional-light-service/testing/context_factory.rb', line 6 def organizer @organizer end |
Class Method Details
.make_from(organizer) ⇒ Object
8 9 10 |
# File 'lib/functional-light-service/testing/context_factory.rb', line 8 def self.make_from(organizer) new(organizer) end |
Instance Method Details
#for(action) ⇒ Object
12 13 14 15 |
# File 'lib/functional-light-service/testing/context_factory.rb', line 12 def for(action) @target_action = action self end |
#with ⇒ Object
More than one arguments can be passed to the Organizer's #call method
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/functional-light-service/testing/context_factory.rb', line 19 def with(...) hook = nil hook = ->(ctx) do if ctx.current_action == @target_action # L'hook non deve essere re-invocato quando il context # verra' usato con Action#execute nel test ctx[:_before_actions].delete(hook) throw(:return_ctx_from_execution, ctx) end end @organizer.append_before_actions(hook) begin catch(:return_ctx_from_execution) do @organizer.call(...) end ensure # L'hook e' per-chiamata: la classe organizer non deve conservarlo @organizer.remove_before_actions(hook) end end |