-
-
Notifications
You must be signed in to change notification settings - Fork 525
Add word count generator #448
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
Conversation
If the prior non-generated version of the test had more tests than what is in x-common, then we need to review the discussions that lead to that difference. Do you feel like the additional tests are something that is Ruby specific? Do you feel that the additional tests may be redundant or a good addition to other languages? |
BTW: Thanks for jumping in here. |
Thanks to you and all the maintainers of this amazing project 😍 The additional cases are:
I think this are valid test that cover cases that are not covered in the x-common cases |
@pvcarrera create a PR in exercism/x-common adding the additional cases to the canonical-data.json file. |
|
||
def object_under_test | ||
"Phrase.new('#{input}')" | ||
end |
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.
Thanks for not calling this do
👍 (like everybody else seems to 😢 )
end | ||
|
||
def skipped? | ||
index > 0 |
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.
Or even index.notzero?
No action needed, just an annotation.
I think I need to update this branch/PR: Merge #451, then remove the generate-word-count scripts. Also, the generated tests don't follow the project style rules. I ran |
Don't worry about updating the branch against 451, you should be able to rebase against master. There is another change (unsure if it is in yet, though) that sets style enforcement/checks back to 0. But this would also be on master. The process for doing this would be on your fork of the project... (Not tested, just written out here as a guide) git checkout master
git pull origin master
git checkout add-word-count-generator
git rebase master That should move your branch to the latest master branch. |
d0c13ac
to
93467be
Compare
Done, I rebased, squashed and forced push. I'm not sure if this is open to discussion, but this is my opinion about PRs workflow: Rebasing an open PR rewrites the PR history, this means that comments are not synchronized with changes anymore. I don't usually rebase/force push once a PR is open, on the other hand, I add commits and merge master in the branch as many times as necessary. Once the PR is ready, I use the GitHub Squash and merge option. This reduces the PR to one commit but still keeps a link to the closed PR request where you can find the original code with its comments. |
I was only stating about rebasing from master, since I changed how the Rubocop is behaving. Thanks for the notes on the PR workflow. It is very similar to how things are normally done here, though we reduce to "a few" if appropriate rather than always a single commit. I did not realize we were ready for that, but you doing so, definitely signals that we are ready for "final approach" on this. |
#451 Common generation script is now in master. |
Cool, this PR is already up to date with #451 |
OK, I attempted to do a generate, might me doing something wrong since it changed recently. |
After I do
|
Looks like its due a to a use of single quotes as you mentioned in #463. I pulled locally and changed the object_under test method as so def object_under_test
"Phrase.new(\"#{input}\")"
end Output:
|
This will still break if the string contains double quotes. |
3439871
to
1c4ca77
Compare
@Insti The input string comes from a json file, example: |
It's still a problem because the json is parsed before we try to insert it. Example: require 'json'
json = { :example => 'Contains " double quote' }.to_json
puts json
input = JSON.parse(json)['example']
puts %Q(Quote not escaped "#{input}") Output:
This might work though:
(Note that the surrounding quotes are now provided by the .to_json method.) Edit: and if input is an array you'll be in trouble too. |
@@ -4,7 +4,7 @@ def name | |||
end | |||
|
|||
def object_under_test | |||
%Q(Phrase.new("#{input}")) | |||
%Q(Phrase.new(#{input.to_json})) |
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.
Sorry to be nitpicky, but..
I think I prefer using inspect
here, since it's not REALLY json that we want.
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.
Yep, I agree inspect
reveals the intention better than to_json
. Thanks
I think this is pretty much ready now. 👍 |
Thanks for all your work on this @pvcarrera ❤️ |
I'm really happy to help, thanks a lot for all of your feedback 😍 |
Thanks @pvcarrera 🎩 to @Insti |
In the list of exercises that need a generator #396 , I saw word-count. Once I started working on it, I found the template
exercises/word-count/example.tt
but I couldn't find any generator associated to it, so I decided to modify the current template and create the generator that you can see in this PR.The
canonical-data.json
file from x-common has less examples that the current version ofword_count_test.rb
Should I add these examples to x-common?