Skip to content

Sinject::Container#register allows class parameter to be nil #15

Description

@KevinBrowne

Sinject::Container#register will check that a class parameter has been provided and raise an error if it is absent. However, it does not check that the class is non-nil.

Steps to reproduce:

require 'sinject'
container = Sinject::Container.new(false)
container.register(key: :foo, class: nil)

Expected:

Sinject::DependencyRegistrationClassNotSpecifiedException or similar to be raised.

Actual:

  • Nothing is raised.

  • container.get(:foo) raises NoMethodError

This is similar to #14, but arguably more serious as nil cannot be a valid class and any errors will be raised after the fact.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions