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

config cleanup with additional test coverage #168

Merged
merged 1 commit into from
Dec 19, 2018

Conversation

SViccari
Copy link
Contributor

Summary:
Update Hubspot.configure to raise when the necessary authentication information is not provided or when two ways of authenticating are provided.

describe "#ensure!" do
subject{ Hubspot::Config.ensure!(:hapikey, :base_url, :portal_id)}
before{ Hubspot::Config.configure(config) }
describe ".ensure!" do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't necessary to update these tests but I opted to update them to remove the calls to should which prints a deprecation warning:

Using should from rspec-expectations' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should with config.expect_with(:rspec) { |c| c.syntax = :should } instead.

Hubspot.configure(hapikey: ENV['HUBSPOT_API_KEY']) unless hapikey.blank?
end
Hubspot.configure(hapikey: hapikey)
yield if block_given?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating the config to raise when the an authentication approach is not set resulted in a few tests failing because the ensure block is setting the hapikey to a nil value.

This method currently:
sets the hapikey to the provided hapikey unless the argument is blank.
runs the block if a block is given
sets the hapikey to the env variable HUBSPOT_API_KEY unless the hapikey is blank.

I think it's safe to simplify this method to rely on an hapikey value being provided and not attempting to set the hapikey to an environment variable. This method is used by the deprecated methods dump_properties and dump_properties.

Copy link

@MattMSumner MattMSumner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@@ -47,6 +48,11 @@ def ensure!(*params)
raise Hubspot::ConfigurationError.new("'#{p}' not configured") unless instance_variable_get "@#{p}"
end
end

private

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about adding a newline between this private line and the next method definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@SViccari SViccari force-pushed the sv-config-cleanup-with-additional-test-coverage branch 2 times, most recently from 114f7ea to 27d40c4 Compare December 19, 2018 14:37
Summary:
Updates the config to raise when the hapikey or oauth access token is
not set or when both values are set.
@SViccari SViccari force-pushed the sv-config-cleanup-with-additional-test-coverage branch from 27d40c4 to 45692fb Compare December 19, 2018 14:43
@SViccari SViccari merged commit 45692fb into master Dec 19, 2018
@SViccari SViccari deleted the sv-config-cleanup-with-additional-test-coverage branch December 19, 2018 15:11
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.

2 participants