bob: added generator#657
Conversation
|
|
||
| def feedback(text) | ||
| "Bob hears #{text.inspect}, and.." | ||
| end |
There was a problem hiding this comment.
This really belongs in the generator, the feedback should be expanded before it gets added to the test.
| "Bob hears #{text.inspect}, and.." | ||
| end | ||
|
|
||
| <% test_cases.each_with_index do |test_case, idx| %> |
There was a problem hiding this comment.
I agree with @Insti use either index or use i. I prefer i in block argument lists when it is used as an index, otherwise I prefer fully expressing the idea as a word.
There was a problem hiding this comment.
I'm totally fine with either. Index is more explicit, so I'll go with that.
| class <%= exercise_name_camel %>Test < Minitest::Test | ||
| def bob | ||
| Bob | ||
| end |
There was a problem hiding this comment.
I honestly just tried to reproduce the test pretty much in it's entirety. I agree this method is especially useless. I'm happy to remove it forever.
|
Looking good @ajwann, you're getting good at these. |
2ed109e to
2448c84
Compare
| def test_other_whitespace | ||
| skip | ||
| remark = " | ||
| " |
There was a problem hiding this comment.
Someones newlines are not being managed in their git configuration?
There was a problem hiding this comment.
There's an explicit \n\r(!) in the test data.
There was a problem hiding this comment.
I honestly think that working with the various newlines that we have to deal with is an important thing... but why in this exercise. Not appropriate to press back here though... should be addressed in x-common.
| remark = "\t" * rand(1..10) | ||
| assert_equal 'Fine. Be that way!', bob.hey(remark), feedback(remark) | ||
| remark = " " | ||
| assert_equal 'Fine. Be that way!', Bob.hey(remark), "Bob hears , and.." |
There was a problem hiding this comment.
The things that Bob hears should be quoted.
%Q can be good for this to help avoid needing to quote quotes.
|
The |
2448c84 to
35e151d
Compare
|
I think we are good to go here. |
| remark = "\t" * rand(1..10) | ||
| assert_equal 'Fine. Be that way!', bob.hey(remark), feedback(remark) | ||
| remark = %Q( ) | ||
| assert_equal 'Fine. Be that way!', Bob.hey(remark), %Q(Bob hears , and..) |
There was a problem hiding this comment.
Still needs quotes around the string Bob hears. (input)
You didn't put the inspects back?
|
|
||
| class BobCase < Generator::ExerciseCase | ||
| def workload | ||
| indent_lines(["remark = %Q(#{input})", |
There was a problem hiding this comment.
Just use inspect here rather than %Q
| class BobCase < Generator::ExerciseCase | ||
| def workload | ||
| indent_lines(["remark = %Q(#{input})", | ||
| "assert_equal '#{expected}', Bob.hey(remark), %Q(Bob hears #{input}, and..)" |
There was a problem hiding this comment.
%Q is right to use here though.
But add an inspect.
"assert_equal '#{expected}', Bob.hey(remark), %Q(Bob hears #{input.inspect}, and..)"There was a problem hiding this comment.
@Insti Adding inspect here actually causes several tests to close the %Q() call early, because those test cases contain literal ) in the actual values. This causes a syntax error on line 101 of the generated test.
If I do something like 'Bob hears #{input.inspect}, and..' then I get the same issue because certain output contains '.
I'm basically trapped in a big catch 22.
There was a problem hiding this comment.
Try doing the same with the %Q but instead use %\Q to escape it. That should reconstruct the invocable line, but ignore it in place.
Let me know.
There was a problem hiding this comment.
%Q can use different delimiters.
https://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Percent+Strings
There was a problem hiding this comment.
Would this work?
def workload
indent_lines(["remark = #{input.inspect}",
"assert_equal '#{expected}', Bob.hey(remark), %q{Bob hears #{input.inspect}, and..}"
], 4)
endThere was a problem hiding this comment.
lowercase %q is better since we don't want it interpolating the string. (the second time)
There was a problem hiding this comment.
@Insti using %q with curly brackets insted of parens did the trick. I had no idea you could use alternative delimiters, thanks!
| def test_other_whitespace | ||
| skip | ||
| remark = %Q( | ||
| ) |
There was a problem hiding this comment.
Using inspect should also make the silly whitespace characters usefully visible.
35e151d to
7c7db85
Compare
|
The calls to |
| require_relative '<%= exercise_name %>' | ||
|
|
||
| # Common test data version: <%= canonical_data_version %> <%= abbreviated_commit_hash %> | ||
| class <%= exercise_name_camel %>Test < Minitest::Test |
There was a problem hiding this comment.
This looks just like the default test template, are there any changes or can it be deleted?
There was a problem hiding this comment.
No changes, it got copied when I copied the generator directory. I'll get rid of it.
7c7db85 to
81184b1
Compare
|
Thanks for all your work on this @ajwann ❤️ ⭐️ |
references #396