Skip to content

enhanced the error message of pick function. #179

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

Merged
merged 1 commit into from
Sep 16, 2013

Conversation

lmello
Copy link
Contributor

@lmello lmello commented Sep 9, 2013

When pick function fail return a better error message like
the other stdlib functions, indicating that the error
is on function pick.

This would help people that see the error to identity it is
related to a incorrect use of stdlib function pick, instead of having
to grep all puppet libraries and manifests source for the old message.

I had also changed the spec test.

@@ -29,6 +29,6 @@
end

it 'should error if no values are passed' do
expect { scope.function_pick([]) }.to raise_error(Puppet::Error, /Must provide non empty value./)
Copy link
Contributor

Choose a reason for hiding this comment

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

Using expect { }.to is preferred over lambda { }.should. In addition it's best practice to do a string match against the error message to ensure that we're catching the right error, instead of any error of the right type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for explaining! I will change that.

@adrienthebo
Copy link
Contributor

Thank you very much for this contribution! I've added some inline comments on this pull request about some stylistic concerns on this pull request, but when those addressed we should be able to get this merged in.

lmello added a commit to lmello/puppetlabs-stdlib that referenced this pull request Sep 12, 2013
Fix the spec test to use expect {}.to instead of lambda {}.should
as explained by Adrienthebo.

"Using expect { }.to is preferred over lambda { }.should.
 In addition it's best practice to do a string match against the
error message to ensure that we're catching the right error,
instead of any error of the right type."

Also fixed a typo on the error message, it was missing one space.
@adrienthebo
Copy link
Contributor

Sorry, one final thing - would you be willing to rebase the two commits in this pull request into a single commit?

@@ -20,10 +20,8 @@ module Puppet::Parser::Functions
args.delete(:undef)
args.delete(:undefined)
args.delete("")
if args[0].to_s.empty? then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

HI Adrien,

I will revert to the previous layout. Will only change the message and the call to fail to raise the correct exception.
Puppet::ParseError

Is that correct ?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be perfect, yes.

@lmello
Copy link
Contributor Author

lmello commented Sep 12, 2013

after making that changes i will rebase into a single commit! :-)

I am trying to improve my ruby skills and decided to contribute to projects I use, as a way to do that.!

@lmello
Copy link
Contributor Author

lmello commented Sep 14, 2013

sorry, did not had time to look over this. on monday i will finish it!

I had removed one wisdom tooth this week. :-/

When pick function fail return a better error message like
the other stdlib functions, indicating that the error
is on function pick.

This would help people that see the error to identity it is
related to a incorrect use of stdlib function pick, instead of having
to grep all puppet libraries and manifests source for the old message.

I had also changed the spec test.

pick function change spec  as suggested puppetlabsGH-179

Fix the spec test to use expect {}.to instead of lambda {}.should
as explained by Adrienthebo.

"Using expect { }.to is preferred over lambda { }.should.
 In addition it's best practice to do a string match against the
error message to ensure that we're catching the right error,
instead of any error of the right type."

Also fixed a typo on the error message, it was missing one space.

pick function stylish fix as suggested on GH179
@lmello
Copy link
Contributor Author

lmello commented Sep 16, 2013

@adrienthebo Please merge. :-)

adrienthebo added a commit that referenced this pull request Sep 16, 2013
enhanced the error message of pick function.
@adrienthebo adrienthebo merged commit ebec9de into puppetlabs:master Sep 16, 2013
@adrienthebo
Copy link
Contributor

summary: merged into master in ebec9de; thanks for the contribution!

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

Successfully merging this pull request may close these issues.

3 participants