{"action":"created","comment":{"url":"https://api.github.com/repos/baxang/coupon-code/pulls/comments/39346681","id":39346681,"diff_hunk":"@@ -0,0 +1,63 @@\n+require 'test_helper'\n+\n+describe 'Validator' do\n+  it 'should be loaded.' do\n+    CouponCode.must_respond_to(:validate)\n+  end\n+\n+  it 'should fail to validate invalid code.' do\n+    CouponCode.validate('').must_equal(nil)\n+  end\n+\n+  it 'should accept a valid code.' do\n+    CouponCode.validate('1K7Q-CTFM-LMTC').wont_be_nil\n+  end\n+\n+  it 'should reject a short code.' do\n+    CouponCode.validate('1K7Q-CTFM').must_be_nil\n+  end\n+\n+  it 'should accept a short code with correct parts.' do\n+    CouponCode.validate('1K7Q-CTFM', 2).wont_be_nil\n+  end\n+\n+  it 'should reject a short code with wrong parts.' do\n+    CouponCode.validate('CTFM-1K7Q', 2).must_be_nil\n+  end\n+\n+  it 'should fix and validate a lowercase code.' do\n+    code = '1k7q-ctfm-lmtc'\n+    CouponCode.validate(code.downcase).must_equal(code.upcase)\n+  end\n+\n+  it 'should validate alternative separators.' do\n+    code = '1k7q/ctfm/lmtc'\n+    CouponCode.validate(code).must_equal('1K7Q-CTFM-LMTC')\n+\n+    code = '1k7q ctfm lmtc'\n+    CouponCode.validate(code).must_equal('1K7Q-CTFM-LMTC')\n+\n+    code = '1k7qctfmlmtc'","path":"test/validator_test.rb","position":40,"original_position":40,"commit_id":"6ddce3da491d7d25930641023c2e2258061a915b","original_commit_id":"6ddce3da491d7d25930641023c2e2258061a915b","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-09-13T11:09:28Z","updated_at":"2015-09-13T11:09:28Z","html_url":"https://github.com/baxang/coupon-code/pull/6#discussion_r39346681","pull_request_url":"https://api.github.com/repos/baxang/coupon-code/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/comments/39346681"},"html":{"href":"https://github.com/baxang/coupon-code/pull/6#discussion_r39346681"},"pull_request":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/baxang/coupon-code/pulls/6","id":44871035,"html_url":"https://github.com/baxang/coupon-code/pull/6","diff_url":"https://github.com/baxang/coupon-code/pull/6.diff","patch_url":"https://github.com/baxang/coupon-code/pull/6.patch","issue_url":"https://api.github.com/repos/baxang/coupon-code/issues/6","number":6,"state":"open","locked":false,"title":"Add configuration","user":{"login":"baxang","id":196302,"avatar_url":"https://avatars.githubusercontent.com/u/196302?v=3","gravatar_id":"","url":"https://api.github.com/users/baxang","html_url":"https://github.com/baxang","followers_url":"https://api.github.com/users/baxang/followers","following_url":"https://api.github.com/users/baxang/following{/other_user}","gists_url":"https://api.github.com/users/baxang/gists{/gist_id}","starred_url":"https://api.github.com/users/baxang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxang/subscriptions","organizations_url":"https://api.github.com/users/baxang/orgs","repos_url":"https://api.github.com/users/baxang/repos","events_url":"https://api.github.com/users/baxang/events{/privacy}","received_events_url":"https://api.github.com/users/baxang/received_events","type":"User","site_admin":false},"body":"Still working in progress.","created_at":"2015-09-13T11:09:23Z","updated_at":"2015-09-13T11:09:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"24652113a0e5e78bfd310743b94f974452821162","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/baxang/coupon-code/pulls/6/commits","review_comments_url":"https://api.github.com/repos/baxang/coupon-code/pulls/6/comments","review_comment_url":"https://api.github.com/repos/baxang/coupon-code/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baxang/coupon-code/issues/6/comments","statuses_url":"https://api.github.com/repos/baxang/coupon-code/statuses/6ddce3da491d7d25930641023c2e2258061a915b","head":{"label":"baxang:add-configuration","ref":"add-configuration","sha":"6ddce3da491d7d25930641023c2e2258061a915b","user":{"login":"baxang","id":196302,"avatar_url":"https://avatars.githubusercontent.com/u/196302?v=3","gravatar_id":"","url":"https://api.github.com/users/baxang","html_url":"https://github.com/baxang","followers_url":"https://api.github.com/users/baxang/followers","following_url":"https://api.github.com/users/baxang/following{/other_user}","gists_url":"https://api.github.com/users/baxang/gists{/gist_id}","starred_url":"https://api.github.com/users/baxang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxang/subscriptions","organizations_url":"https://api.github.com/users/baxang/orgs","repos_url":"https://api.github.com/users/baxang/repos","events_url":"https://api.github.com/users/baxang/events{/privacy}","received_events_url":"https://api.github.com/users/baxang/received_events","type":"User","site_admin":false},"repo":{"id":28193429,"name":"coupon-code","full_name":"baxang/coupon-code","owner":{"login":"baxang","id":196302,"avatar_url":"https://avatars.githubusercontent.com/u/196302?v=3","gravatar_id":"","url":"https://api.github.com/users/baxang","html_url":"https://github.com/baxang","followers_url":"https://api.github.com/users/baxang/followers","following_url":"https://api.github.com/users/baxang/following{/other_user}","gists_url":"https://api.github.com/users/baxang/gists{/gist_id}","starred_url":"https://api.github.com/users/baxang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxang/subscriptions","organizations_url":"https://api.github.com/users/baxang/orgs","repos_url":"https://api.github.com/users/baxang/repos","events_url":"https://api.github.com/users/baxang/events{/privacy}","received_events_url":"https://api.github.com/users/baxang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/baxang/coupon-code","description":"Generate and validate coupon codes.","fork":false,"url":"https://api.github.com/repos/baxang/coupon-code","forks_url":"https://api.github.com/repos/baxang/coupon-code/forks","keys_url":"https://api.github.com/repos/baxang/coupon-code/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baxang/coupon-code/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baxang/coupon-code/teams","hooks_url":"https://api.github.com/repos/baxang/coupon-code/hooks","issue_events_url":"https://api.github.com/repos/baxang/coupon-code/issues/events{/number}","events_url":"https://api.github.com/repos/baxang/coupon-code/events","assignees_url":"https://api.github.com/repos/baxang/coupon-code/assignees{/user}","branches_url":"https://api.github.com/repos/baxang/coupon-code/branches{/branch}","tags_url":"https://api.github.com/repos/baxang/coupon-code/tags","blobs_url":"https://api.github.com/repos/baxang/coupon-code/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baxang/coupon-code/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baxang/coupon-code/git/refs{/sha}","trees_url":"https://api.github.com/repos/baxang/coupon-code/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baxang/coupon-code/statuses/{sha}","languages_url":"https://api.github.com/repos/baxang/coupon-code/languages","stargazers_url":"https://api.github.com/repos/baxang/coupon-code/stargazers","contributors_url":"https://api.github.com/repos/baxang/coupon-code/contributors","subscribers_url":"https://api.github.com/repos/baxang/coupon-code/subscribers","subscription_url":"https://api.github.com/repos/baxang/coupon-code/subscription","commits_url":"https://api.github.com/repos/baxang/coupon-code/commits{/sha}","git_commits_url":"https://api.github.com/repos/baxang/coupon-code/git/commits{/sha}","comments_url":"https://api.github.com/repos/baxang/coupon-code/comments{/number}","issue_comment_url":"https://api.github.com/repos/baxang/coupon-code/issues/comments{/number}","contents_url":"https://api.github.com/repos/baxang/coupon-code/contents/{+path}","compare_url":"https://api.github.com/repos/baxang/coupon-code/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baxang/coupon-code/merges","archive_url":"https://api.github.com/repos/baxang/coupon-code/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baxang/coupon-code/downloads","issues_url":"https://api.github.com/repos/baxang/coupon-code/issues{/number}","pulls_url":"https://api.github.com/repos/baxang/coupon-code/pulls{/number}","milestones_url":"https://api.github.com/repos/baxang/coupon-code/milestones{/number}","notifications_url":"https://api.github.com/repos/baxang/coupon-code/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baxang/coupon-code/labels{/name}","releases_url":"https://api.github.com/repos/baxang/coupon-code/releases{/id}","created_at":"2014-12-18T17:18:23Z","updated_at":"2015-07-06T04:37:11Z","pushed_at":"2015-09-13T11:09:23Z","git_url":"git://github.com/baxang/coupon-code.git","ssh_url":"git@github.com:baxang/coupon-code.git","clone_url":"https://github.com/baxang/coupon-code.git","svn_url":"https://github.com/baxang/coupon-code","homepage":null,"size":278,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":12,"default_branch":"master"}},"base":{"label":"baxang:master","ref":"master","sha":"843a3db9a8af11b304cc729298807c3f22f6105a","user":{"login":"baxang","id":196302,"avatar_url":"https://avatars.githubusercontent.com/u/196302?v=3","gravatar_id":"","url":"https://api.github.com/users/baxang","html_url":"https://github.com/baxang","followers_url":"https://api.github.com/users/baxang/followers","following_url":"https://api.github.com/users/baxang/following{/other_user}","gists_url":"https://api.github.com/users/baxang/gists{/gist_id}","starred_url":"https://api.github.com/users/baxang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxang/subscriptions","organizations_url":"https://api.github.com/users/baxang/orgs","repos_url":"https://api.github.com/users/baxang/repos","events_url":"https://api.github.com/users/baxang/events{/privacy}","received_events_url":"https://api.github.com/users/baxang/received_events","type":"User","site_admin":false},"repo":{"id":28193429,"name":"coupon-code","full_name":"baxang/coupon-code","owner":{"login":"baxang","id":196302,"avatar_url":"https://avatars.githubusercontent.com/u/196302?v=3","gravatar_id":"","url":"https://api.github.com/users/baxang","html_url":"https://github.com/baxang","followers_url":"https://api.github.com/users/baxang/followers","following_url":"https://api.github.com/users/baxang/following{/other_user}","gists_url":"https://api.github.com/users/baxang/gists{/gist_id}","starred_url":"https://api.github.com/users/baxang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baxang/subscriptions","organizations_url":"https://api.github.com/users/baxang/orgs","repos_url":"https://api.github.com/users/baxang/repos","events_url":"https://api.github.com/users/baxang/events{/privacy}","received_events_url":"https://api.github.com/users/baxang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/baxang/coupon-code","description":"Generate and validate coupon codes.","fork":false,"url":"https://api.github.com/repos/baxang/coupon-code","forks_url":"https://api.github.com/repos/baxang/coupon-code/forks","keys_url":"https://api.github.com/repos/baxang/coupon-code/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baxang/coupon-code/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baxang/coupon-code/teams","hooks_url":"https://api.github.com/repos/baxang/coupon-code/hooks","issue_events_url":"https://api.github.com/repos/baxang/coupon-code/issues/events{/number}","events_url":"https://api.github.com/repos/baxang/coupon-code/events","assignees_url":"https://api.github.com/repos/baxang/coupon-code/assignees{/user}","branches_url":"https://api.github.com/repos/baxang/coupon-code/branches{/branch}","tags_url":"https://api.github.com/repos/baxang/coupon-code/tags","blobs_url":"https://api.github.com/repos/baxang/coupon-code/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baxang/coupon-code/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baxang/coupon-code/git/refs{/sha}","trees_url":"https://api.github.com/repos/baxang/coupon-code/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baxang/coupon-code/statuses/{sha}","languages_url":"https://api.github.com/repos/baxang/coupon-code/languages","stargazers_url":"https://api.github.com/repos/baxang/coupon-code/stargazers","contributors_url":"https://api.github.com/repos/baxang/coupon-code/contributors","subscribers_url":"https://api.github.com/repos/baxang/coupon-code/subscribers","subscription_url":"https://api.github.com/repos/baxang/coupon-code/subscription","commits_url":"https://api.github.com/repos/baxang/coupon-code/commits{/sha}","git_commits_url":"https://api.github.com/repos/baxang/coupon-code/git/commits{/sha}","comments_url":"https://api.github.com/repos/baxang/coupon-code/comments{/number}","issue_comment_url":"https://api.github.com/repos/baxang/coupon-code/issues/comments{/number}","contents_url":"https://api.github.com/repos/baxang/coupon-code/contents/{+path}","compare_url":"https://api.github.com/repos/baxang/coupon-code/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baxang/coupon-code/merges","archive_url":"https://api.github.com/repos/baxang/coupon-code/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baxang/coupon-code/downloads","issues_url":"https://api.github.com/repos/baxang/coupon-code/issues{/number}","pulls_url":"https://api.github.com/repos/baxang/coupon-code/pulls{/number}","milestones_url":"https://api.github.com/repos/baxang/coupon-code/milestones{/number}","notifications_url":"https://api.github.com/repos/baxang/coupon-code/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baxang/coupon-code/labels{/name}","releases_url":"https://api.github.com/repos/baxang/coupon-code/releases{/id}","created_at":"2014-12-18T17:18:23Z","updated_at":"2015-07-06T04:37:11Z","pushed_at":"2015-09-13T11:09:23Z","git_url":"git://github.com/baxang/coupon-code.git","ssh_url":"git@github.com:baxang/coupon-code.git","clone_url":"https://github.com/baxang/coupon-code.git","svn_url":"https://github.com/baxang/coupon-code","homepage":null,"size":278,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/6"},"html":{"href":"https://github.com/baxang/coupon-code/pull/6"},"issue":{"href":"https://api.github.com/repos/baxang/coupon-code/issues/6"},"comments":{"href":"https://api.github.com/repos/baxang/coupon-code/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baxang/coupon-code/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/baxang/coupon-code/statuses/6ddce3da491d7d25930641023c2e2258061a915b"}}}}