Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KevinBrowne opened this issue Feb 21, 2024 · 0 comments
Open

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

KevinBrowne opened this issue Feb 21, 2024 · 0 comments
Labels

Comments

@KevinBrowne
Copy link
Member

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.

@KevinBrowne KevinBrowne changed the title Sinject::Container#register allows key parameter to be nil Sinject::Container#register allows class parameter to be nil Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant