class LightService::Testing::ContextFactory
Attributes
Public Class Methods
Source
# File lib/light-service/testing/context_factory.rb, line 6 def self.make_from(organizer) new(organizer) end
Source
# File lib/light-service/testing/context_factory.rb, line 39 def initialize(organizer) @organizer = organizer end
Public Instance Methods
Source
# File lib/light-service/testing/context_factory.rb, line 10 def for(action) @organizer.append_before_actions( lambda do |ctx| if ctx.current_action == action # The last `:_before_actions` hook is for # ContextFactory, remove it, so it won't # be invoked again ctx[:_before_actions].pop throw(:return_ctx_from_execution, ctx) end end ) self end
Source
# File lib/light-service/testing/context_factory.rb, line 30 def with(*args, &block) catch(:return_ctx_from_execution) do @organizer.call(*args, &block) end end
More than one arguments can be passed to the Organizer’s call method rubocop:disable Style/ArgumentsForwarding