Luhn with generator#559
Conversation
Cases and template seem to be very simple, and may be used in documenting this process.
|
Failing due to Ruby version not having |
Insti
left a comment
There was a problem hiding this comment.
Looks good, it generates a correct looking test file which is the main thing.
| class LuhnTest < Minitest::Test<% test_cases.each do |test_case| %> | ||
| def <%= test_case.name %> | ||
| <%= test_case.skipped %> | ||
| <%= test_case.assertion %> <%= test_case.work_load %> |
There was a problem hiding this comment.
test_case.workload should include the assertion.
So this line can be simplified to: <%= test_case.workload %>
| index.zero? ? '# skip' : 'skip' | ||
| end | ||
|
|
||
| def assertion |
There was a problem hiding this comment.
This can be made private as it is only needed by workload
|
|
||
| def work_load | ||
| %Q(Luhn.valid?("#{input}")) | ||
| %Q(#{assertion} Luhn.valid?("#{input}")) |
There was a problem hiding this comment.
"#{input}"
This will work, but it's a good habit to use input.inspect which will handle input that contains quotes.
Nice usage of %Q though. 👍
| 'test_%s' % description.tr('- ', '__') | ||
| end | ||
|
|
||
| def work_load |
There was a problem hiding this comment.
I've updated the documentation to help clarify this: #560
There was a problem hiding this comment.
Is there a style guide somewhere (other than the README)? Because some of the exercises use work_load and others use workload. In fact, as long as it is the same in both example.tt and <exercise>_cases.rb it should work fine.
There was a problem hiding this comment.
No, just the README.
I've made a PR to rename the old occurrences to try and clear this up: #561
|
Thanks for doing this @hilary ❤️ It will be some non-deterministic amount of time until this change is visible as it requires Katrina to do a release to the live site, but that will probably happen sometime in the next day or two. |
Description
Added Generator for Luhn for new Luhn canonical data
Motivation and Context
The Luhn exercise had some weaknesses (exercism/problem-specifications#474) which have now been addressed via canonical data (exercism/problem-specifications#491).
How Has This Been Tested?
We ran
rake testTypes of changes
References and Closures
Checklist: