Class: LightService::Testing::ContextFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/light-service/testing/context_factory.rb

Defined Under Namespace

Classes: ContextFactoryOrganizer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organizer) ⇒ ContextFactory

Returns a new instance of ContextFactory.



30
31
32
# File 'lib/light-service/testing/context_factory.rb', line 30

def initialize(organizer)
  @organizer = organizer
end

Instance Attribute Details

#organizerObject (readonly)

Returns the value of attribute organizer.



15
16
17
# File 'lib/light-service/testing/context_factory.rb', line 15

def organizer
  @organizer
end

Class Method Details

.make_from(organizer) ⇒ Object



17
18
19
# File 'lib/light-service/testing/context_factory.rb', line 17

def self.make_from(organizer)
  new(organizer)
end

Instance Method Details

#find_up_to(action) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/light-service/testing/context_factory.rb', line 34

def find_up_to(action)
  original_actions = organizer.actions

  original_actions.take_while do |current_action|
    current_action != action
  end
end

#for(action) ⇒ Object



21
22
23
24
# File 'lib/light-service/testing/context_factory.rb', line 21

def for(action)
  ContextFactoryOrganizer.actions = find_up_to(action)
  self
end

#with(ctx) ⇒ Object



26
27
28
# File 'lib/light-service/testing/context_factory.rb', line 26

def with(ctx)
  ContextFactoryOrganizer.call(ctx)
end