Skip to content

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

@KevinBrowne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions