duckduckgo / zeroclickinfo-goodies

DuckDuckGo Instant Answers based on Perl & JavaScript
https://duckduckhack.com/
Other
979 stars 1.76k forks source link

duckpan test CheatSheets failure #3418

Closed ghost closed 8 years ago

ghost commented 8 years ago

I'm creating a code cheat sheet for a Ruby Gem called webcomics. This is my first ever cheat sheet and I've been following along with the steps provided in the doc Make a Cheat Sheet I got to the part where I had to validate my cheat sheet. I validated my json then I went to go validate my cheat sheet and I got two errors:

  1. -> FAIL: Invalid file name (ruby_webcomics_reference_documentation_cheat_sheet.json) for ID (ruby_webcomics_reference_documentation_cheat_sheet_cheat_sheet)
  2. -> FAIL: No Instant Answer page found with ID 'ruby_webcomics_reference_documentation_cheat_sheet_cheat_sheet'

It's strange to me that It says Failed test 'FAIL: No Instant Answer page found with ID 'ruby_webcomics_reference_documentation_cheat_sheet_cheat_sheet'' because on my IA page the id and the one my json file are the same.

I don't understand these errors what might be wrong and how can I fix this?

moollaza commented 8 years ago

@Mav7 your IA Page was not yet public, because there was no associated Pull Request.

I've now made the IA Page public so your tests should now pass. Please open a Pull Request and paste the link to you IA Page (even if your code isn't finished yet).

ghost commented 8 years ago

@moollaza I think I found the issue. I'm trying to just get the results of my cheat sheet locally so the 2nd error: -> FAIL: No Instant Answer page found with ID 'ruby_webcomics_reference_documentation_cheat_sheet_cheat_sheet' Isn't an issue yet. When I run duckpan server and test my cheat sheet for some reason when it's a name with spaces like ruby_webcomics_reference_documentation_cheat_sheet_cheat_sheet it doesn't work and I get Sorry, no hit for your instant answer but when I do one word like webcomics it works perfectly and I get to see my cheat sheet! I've tried this multiple times with other names like tester1 v.s. the tester1 and the results are the same. My cheat sheet works successfully on the local server only when I use one word. Which is odd to me because I followed what the documentation said to do when the name of my cheat sheet is one word. Type regex1 (since regex already exists in the repository, we'll add a character for this tutorial). If the name contains more than one word, separate them with space. The tool will do the rest http://docs.duckduckhack.com/walkthroughs/programming-syntax.html. When I do this the generated file is something like ruby_webcomics_reference_documentation_cheat_sheet.json instead of something like sublime-text.json. So I deleted the old .json and generated a new one using duckpan new --template cheatsheet. This time typing in ruby-webcomics-reference-documentation-cheat-sheet.json but I get an error saying: [FATAL] 'ruby-webcomics-reference-documentation-cheat-sheet.json' is not a valid name for an Instant Answer. Please run the program again and provide a valid name.. So why is this? How can I get an IA name with more than one word to work?

GuiltyDolphin commented 8 years ago

@mav Could you run duckpan upgrade and ensure your branch is up to date with the master branch then try again? We had a couple of issues with the cheat sheet template a while back.

ghost commented 8 years ago

@GuiltyDolphin I ran duckpan upgrade but the problem still persists, unfortunately. Perhaps I did something wrong. Do I just run duckpan upgrade in my codio environment? Or might there be more steps?

GuiltyDolphin commented 8 years ago

@Mav7 So you run duckpan new --template cheatsheet then you type ruby webcomics reference documentation, right? And you're up-to-date with the master branch? git checkout master && git fetch upstream && git merge upstream/master master && git checkout my-other-branch && git rebase master

ghost commented 8 years ago

@GuiltyDolphin @moollaza Thanks for all the help but the problem still persists. I'm fine though I'm just using the name webcomics for the cheat sheet and the cheat was merged earlier.

moollaza commented 8 years ago

@Mav7 to clarify, you're saying you provide names with spaces to duckpan new, instead of a filename generated with - you're getting _.

Meaning this is not the result you get:

❯ duckpan new --cheatsheet testing this out 
Creating a new Cheat Sheet Instant Answer...
Created files:
    share/goodie/cheat_sheets/json/testing-this-out.json
Success!

Note I just found there's a bug with names containing single letter words. They get bunched together with the next word instead of fully separated:

❯ duckpan new --cheatsheet testing this a thing a one more a time
Creating a new Cheat Sheet Instant Answer...
Created files:
    share/goodie/cheat_sheets/json/testing-this-athing-aone-more-atime.json
Success!
moollaza commented 8 years ago

Providing a name with - already separating the words should be considered valid. Likewise we can also accept names with _ by simply replacing any "-" or "_" with a space first.

ghost commented 8 years ago

@moollaza Ah I see! I did it exactly how the documentation laid it out like this: duckpan new --template cheatsheet Please enter a name for your Instant Answer: I would type the name of the IA after this part Please enter a name for your Instant Answer: Now when I do it the way you just pointed out here it works! This is wonderful thank you!

moollaza commented 8 years ago

@Mav7 entering the name when prompted should have the same effect:

❯ duckpan new --cheatsheet
Creating a new Cheat Sheet Instant Answer...
Please enter a name for your Instant Answer: testing this out
Created files:
    share/goodie/cheat_sheets/json/testing-this-out.json
Success!

Are you not getting those ^ results?

moollaza commented 8 years ago

@Mav7 I've realized that the --template cheatsheet does incorrectly use _ instead of - to separate the words in the JSON filename.

I've updated the documentation to use the duckpan new --cheatsheet method which does work. I made an issue to fix the incorrect filename generation as well

ghost commented 8 years ago

@moollaza Thank you so much for your help! I actually have PR for my cheatsheet here and it's still up for review #3483.