-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix(sprint_cleaner): fixes default arguments of the sprint cleaner #199
fix(sprint_cleaner): fixes default arguments of the sprint cleaner #199
Conversation
Could you please also add a test which exposes the bug? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as @cornelius says, a test case would be nice 😉
@@ -15,7 +15,8 @@ | |||
|
|||
it 'moves remaining cards to target board', vcr: 'sprint_cleanup', vcr_record: false do | |||
expect(STDOUT).to receive(:puts).exactly(13).times | |||
expect(subject.cleanup('7Zar7bNm', '72tOJsGS', set_last_sprint_label: true)).to be | |||
set_last_sprint_label = true | |||
expect(subject.cleanup('7Zar7bNm', '72tOJsGS', set_last_sprint_label)).to be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about
expect(subject.cleanup('7Zar7bNm', '72tOJsGS', true).to be
instead of an extra variable? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, cornelius had earlier suggested that the extra verbosity, because he thought that the purpose of that third parameter wasn't evident. So he suggested moving to a named parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ana06 the expection arose due to using named parameters. when no value for the last parameter was passed it threw ArgumentError
. Now that've moved to default params, that error won't be occuring anymore. I'm not sure how I'm supposed to write a test for that. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankitkataria The extra verbosity I suggested was not for the test. With a positional parameter you indeed should just call it without an extra variable. My point was about the signature of the function so that when you call it you are forced to provide a named parameter instead of a boolean. When you read the code where the function is called it's then obvious what it does. When there is only a false
or true
as a parameter you need to look up the definition of the function to understand what the calling code does. That's why for booleans named parameters are generally preferrable.
Regarding the test, what would be ideal is, if you write a test which fails with the old version of the code. That would expose the bug that the code didn't work anymore when no parameter was given. This test should go into the tests of the Cli
class because that's where the issue occurred. When you then apply a fix the test will be green and it will be guaranteed that it won't occur again, because there is a test now. That's he gist of test-driven development.
As for the fix I think you should fix it in the Cli
class when calling the method, not going back to positional parameters.
Hope that clear up what I was thinking :-)
- moves back to names parameters, fixes the call to cleanup function in cli.rb - adds test in cli_spec to not raise an argument error - adds test in sprint_cleaner_spec for when the argument error is raised
8b56a34
to
a71c7f8
Compare
a71c7f8
to
6da746e
Compare
Thank you for the really elaborate explanation @cornelius 😄! I fixed it in |
This looks much better. There still is an issue with the tests. You check for not raising an It would be better to check that no error is raised and make sure that the test environment is set up in a way that this doesn't happen. We have the helper methods to mock a full board. Maybe they can be used? |
- now test expects to not raise any error - mocked the planinng and target boards
@cornelius added mocking of the planning and target boards. 😉 Also fixed a minor typo in |
Hi! @cornelius @Ana06 😄! what all is left to be done in this PR? |
@ankitkataria there was a change to the cli interface. The code is moved to |
@ankitkataria do you need help to do the changes? if so, please let us know 😉 |
prevent
ArgumentError
sprint_cleaner_spec
verbose to make sense of its purposeFixes #197