adomokos / light-service

Series of Actions with an emphasis on simplicity.
MIT License
837 stars 67 forks source link

ContextFactory will execute the entire Organizer when passed an unused Action #145

Closed jeremy-hanna closed 6 years ago

jeremy-hanna commented 6 years ago

Like the title says, if you pass an Action into the ContextFactory that is outside the Action set of an Organizer the entire Organizer is executed with no errors raised or indication that this happened. Given the nature of development, the scenario where a user (developer) renames an Action is highly likely and dependant specs will still pass but execute the whole context with no indication to the user.

This is misleading to the developer, who expects the Organizer to execute up-to a specific action and not more. If provided an unreferenced action in the supplied Organizer, the ContextFactory should raise an error about it.

Failing spec:

context 'when called with an invalid action' do
  let(:organizer)      { TestDoubles::AdditionOrganizer }
  let(:invalid_action) { TestDoubles::MakesLatteAction }

  it 'raises an argument error' do
    expect do
      LightService::Testing::ContextFactory
        .make_from(organizer)
        .for(invalid_action)
        .with(1)
    end.to raise_error(
      ArgumentError,
      "Could not find #{invalid_action} in #{organizer}"
    )
  end
end

Proposed Solution: https://github.com/adomokos/light-service/pull/141#discussion_r178331102

adomokos commented 6 years ago

@jeremy-hanna - is this still an issue? It seems a fix has been merged for it.