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

change: Regenerate Tests #871

Merged
merged 2 commits into from
Oct 20, 2018
Merged

Conversation

pgaspar
Copy link
Member

@pgaspar pgaspar commented Oct 5, 2018

Update change tests to: 1.3.0 258c807

Update generator to use the standard error indicator.
Update solution to pass updated tests.

Update generator to use the standard error indicator.
Update solution to pass updated tests.
@@ -45,16 +45,22 @@ def test_no_coins_make_0_change

def test_error_testing_for_change_smaller_than_the_smallest_of_coins
skip
assert_equal -1, Change.generate([5, 10], 3)
assert_raises(ArgumentError) do
Change.generate([5, 10], 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

ArgumentError is probably OK here, but what about returning a subclass which is more descriptive?

end

def test_error_if_no_combination_can_add_up_to_target
skip
assert_equal -1, Change.generate([5, 10], 94)
assert_raises(ArgumentError) do
Change.generate([5, 10], 94)
Copy link
Contributor

Choose a reason for hiding this comment

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

ArgumentError is probably not appropriate here.
Maybe nil or a custom error?

end

def test_cannot_find_negative_change_values
skip
assert_equal -1, Change.generate([1, 2, 5], -5)
assert_raises(ArgumentError) do
Change.generate([1, 2, 5], -5)
Copy link
Contributor

@Insti Insti Oct 5, 2018

Choose a reason for hiding this comment

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

ArgumentError is reasonable here. 👍

(I don't think invalid input like this is something we should be testing for, but that's an unrelated issue. (and very much a matter of opinion.))

@pgaspar
Copy link
Member Author

pgaspar commented Oct 16, 2018

Hello @iHiD! Thank you for your review. Wanted us to deal with #870 before this one, that's why I took so long to answer.

I understand and agree with your points, but I have a question:

Given how all 3 of these "error cases" are specified on the canonical data as "expected": {"error": ...}, how do you typically differentiate between them in the change_case.rb file? Should I check for the test name using something like this?

@Insti
Copy link
Contributor

Insti commented Oct 16, 2018

I assume you meant @Insti there :)

Yeah you'll need to do something like that. Either check the test name or error text I guess.

@iHiD
Copy link
Member

iHiD commented Oct 16, 2018

Ah! I was confused :)

@pgaspar
Copy link
Member Author

pgaspar commented Oct 16, 2018

Oh no! Sorry @iHiD 😅 Wrote that in a hurry and didn't notice it!

@Insti Thanks 👍 I'll work on something soon.

@pgaspar
Copy link
Member Author

pgaspar commented Oct 19, 2018

@Insti I just pushed some tentative changes. I didn't follow your suggestions to the letter, but wanted to get your opinion regardless.

Please let me know what you think. I also appreciate suggestions for better error names 👍

@pgaspar pgaspar force-pushed the change-regenerate-tests branch from cb7ff87 to 6c023f5 Compare October 19, 2018 01:58
@@ -1,18 +1,23 @@
class Change
attr_reader :coins, :target

class NegativeTargetError < ArgumentError; end
class ImpossibleCombinationError < StandardError; end
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like these two 👍

Copy link
Contributor

@Insti Insti left a comment

Choose a reason for hiding this comment

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

I think this looks good and does everything it needs to do now.

@Insti
Copy link
Contributor

Insti commented Oct 19, 2018

Do you think this is ready to merge now @pgaspar ?

@pgaspar
Copy link
Member Author

pgaspar commented Oct 19, 2018

I think so @Insti! Thank you 👍

@Insti Insti merged commit 46af51e into exercism:master Oct 20, 2018
@Insti
Copy link
Contributor

Insti commented Oct 20, 2018

Thanks for all your work on these @pgaspar ❤️

@pgaspar pgaspar deleted the change-regenerate-tests branch October 22, 2018 19:06
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.

3 participants