Skip to content

Throw error on nonalphanumeric namespace - #3

Open
goodmike wants to merge 2 commits into
primaryobjects:masterfrom
goodmike:error_on_nonalphanumeric_namespace
Open

goodmike wants to merge 2 commits into
primaryobjects:masterfrom
goodmike:error_on_nonalphanumeric_namespace

Conversation

@goodmike

@goodmike goodmike commented Dec 30, 2016 •

Copy link
Copy Markdown

[Closes #2]

Here's the PR to prevent users from accidentally choosing a namespace for a skill that will cause errors later.

I have 2 separate commits. The first sets up a minimal tape test environment and a single unit test for the error. If you're like me, you're more comfortable squashing a bug when there's a test to demonstrate it's fixed. However, if you don't want the dev dependency on tape, which also pulls a number of other packages in (even though it's supposed to be the lightweight testing alternative), or you prefer a different library like mocha or jasmine, feel free to ask me to discard or change this commit.

The second commit has the actual edit to chatskills.js. I decided to keep it as simple as I could, so I have a RegExp test for non-alphanumerics. I did not extract the namespace part of the RegExp expression in the session method because I think it would be difficult to use the partial pattern both in the add method and the session method. I don't think RegExps do not compose easily. Again, if you'd prefer I try to DRY things out, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant