Skip to content

Fix const_get arguments in api models #428

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coiti
Copy link

@coiti coiti commented May 29, 2025

Hubspot::Discovery::BaseApiClient#require_api_models overrides the const_get method for generated classes under certain circumstances, but the override only accepts one argument, whereas the original Module#const_get accepts two. This can be a problem when mocking these classes in tests, such as when using instance_double from rspec-mocks.

For example:

Failure/Error: let(:hubspot_company_object) { instance_double(Hubspot::Crm::Companies::SimplePublicObject) }
     
ArgumentError:
  wrong number of arguments (given 2, expected 1)

This fixes that by adding anonymous arguments to the method override, letting the super call handle the extra argument.

Accept more than one argument for the const_get method override in
Hubspot::Discovery::BaseApiClient#require_api_models to keep
compatibility with Module.const_get, which takes two arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant