{"action":"created","comment":{"url":"https://api.github.com/repos/BBC-News/wraith/pulls/comments/48382693","id":48382693,"diff_hunk":"@@ -0,0 +1,84 @@\n+require \"_helpers\"\n+\n+describe \"Wraith config validator\" do\n+\n+  let(:config) {\n+    YAML.load('\n+      domains:\n+        test: http://www.bbc.com\n+\n+      browser: \"casperjs\"\n+    ')\n+  }\n+\n+  describe \"universal, basic validation for all modes\" do\n+\n+    it \"should validate a basic config\" do\n+      validate = Wraith::Validate.new(config, true).validate\n+    end\n+\n+    it \"should complain if the `domains` property is missing\" do\n+      config['domains'] = nil\n+      expect { Wraith::Validate.new(config, true).validate }.to raise_error MissingRequiredPropertyError\n+    end\n+\n+    it \"should complain if the `browser` property is missing\" do\n+      config['browser'] = nil\n+      expect { Wraith::Validate.new(config, true).validate }.to raise_error MissingRequiredPropertyError\n+    end\n+\n+  end\n+\n+  describe \"validation specific to capture mode\" do\n+\n+    it \"should complain if fewer than two domains are specified\" do\n+      expect { Wraith::Validate.new(config, true).validate('capture') }.to raise_error InvalidDomainsError\n+    end\n+\n+    it \"should complain if more than two domains are specified\" do\n+      config['domains'] = YAML.load('\n+        test:  http://something.bbc.com\n+        stage: http://something-else.bbc.com\n+        live:  http://www.bbc.com\n+      ')\n+      expect { Wraith::Validate.new(config, true).validate('capture') }.to raise_error InvalidDomainsError\n+    end\n+\n+    it \"should be happy if exactly two domains are specified\" do\n+      config['domains'] = YAML.load('\n+          test:  http://something.bbc.com\n+          live:  http://www.bbc.com\n+      ')\n+      validate = Wraith::Validate.new(config, true).validate('capture')\n+    end\n+\n+  end\n+\n+  describe \"validations specific to history mode\" do\n+\n+    let(:history_conf) {\n+      config.merge(YAML.load('\n+        history_dir: \"history_shots\"\n+      '))\n+    }\n+\n+    it \"should complain if more than one domain is specified\" do\n+      history_conf['domains'] = YAML.load('\n+        test: http://something.bbc.com\n+        live: http://www.bbc.com\n+      ')\n+      expect { Wraith::Validate.new(history_conf, true).validate('history') }.to raise_error InvalidDomainsError\n+    end\n+\n+    it \"should complain if no history_dir is specified\" do\n+      history_conf['history_dir'] = nil\n+      expect { Wraith::Validate.new(history_conf, true).validate('history') }.to raise_error MissingRequiredPropertyError\n+    end\n+\n+    it \"should be happy if a history_dir and one domain is specified\" do\n+      validate = Wraith::Validate.new(history_conf, true).validate('history')\n+    end\n+","path":"spec/validate_spec.rb","position":81,"original_position":81,"commit_id":"b4926e881eb7dc6cda2289ef9d256419a5026f49","original_commit_id":"b4926e881eb7dc6cda2289ef9d256419a5026f49","user":{"login":"DaveBlooman","id":1492067,"avatar_url":"https://avatars.githubusercontent.com/u/1492067?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBlooman","html_url":"https://github.com/DaveBlooman","followers_url":"https://api.github.com/users/DaveBlooman/followers","following_url":"https://api.github.com/users/DaveBlooman/following{/other_user}","gists_url":"https://api.github.com/users/DaveBlooman/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBlooman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBlooman/subscriptions","organizations_url":"https://api.github.com/users/DaveBlooman/orgs","repos_url":"https://api.github.com/users/DaveBlooman/repos","events_url":"https://api.github.com/users/DaveBlooman/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBlooman/received_events","type":"User","site_admin":false},"body":"remove space","created_at":"2015-12-23T22:00:41Z","updated_at":"2015-12-23T22:00:41Z","html_url":"https://github.com/BBC-News/wraith/pull/361#discussion_r48382693","pull_request_url":"https://api.github.com/repos/BBC-News/wraith/pulls/361","_links":{"self":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/comments/48382693"},"html":{"href":"https://github.com/BBC-News/wraith/pull/361#discussion_r48382693"},"pull_request":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/361"}}},"pull_request":{"url":"https://api.github.com/repos/BBC-News/wraith/pulls/361","id":54484456,"html_url":"https://github.com/BBC-News/wraith/pull/361","diff_url":"https://github.com/BBC-News/wraith/pull/361.diff","patch_url":"https://github.com/BBC-News/wraith/pull/361.patch","issue_url":"https://api.github.com/repos/BBC-News/wraith/issues/361","number":361,"state":"open","locked":false,"title":"[ready for review] Wraith 3.1","user":{"login":"ChrisBAshton","id":5111927,"avatar_url":"https://avatars.githubusercontent.com/u/5111927?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisBAshton","html_url":"https://github.com/ChrisBAshton","followers_url":"https://api.github.com/users/ChrisBAshton/followers","following_url":"https://api.github.com/users/ChrisBAshton/following{/other_user}","gists_url":"https://api.github.com/users/ChrisBAshton/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisBAshton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisBAshton/subscriptions","organizations_url":"https://api.github.com/users/ChrisBAshton/orgs","repos_url":"https://api.github.com/users/ChrisBAshton/repos","events_url":"https://api.github.com/users/ChrisBAshton/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisBAshton/received_events","type":"User","site_admin":false},"body":"*Before merging*:\r\n\r\n* get code reviewed\r\n* bump version number\r\n\r\n# Wraith 3.1\r\nThis PR (done as part of [milestone 3.1](https://github.com/BBC-News/wraith/milestones/3.1)) introduces:\r\n\r\n* significant bug fixes for PhantomJS users\r\n* bug fix for Windows users (no longer directly use `pwd` commands)\r\n* bug fix for CasperJS users (can now use ID selectors - the hashtag symbol is escaped before being passed to CLI)\r\n* validation, giving users helpful error messages if they try to misuse Wraith\r\n* expanded test suite (`construct_command` tests, validation tests)\r\n* better default example configs and before_capture hooks\r\n* asynchronous support for the before_capture hook. This introduces a breaking change (see next section)\r\n* verbose mode (just add `verbose: true` to your config. Easier debugging)\r\n* 'debug' functionality (built into verbose mode). Starts off the output of all commands with system-specific information which should help with debugging. For example, here's mine:\r\n\r\n```\r\n#################################################\r\n  Wraith version:     3.0.4\r\n  Ruby version:       ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin13.1.0]\r\n  ImageMagick:        Version: ImageMagick 6.9.1-3 Q16 x86_64 2015-05-25 http://www.imagemagick.org\r\n  PhantomJS version:  1.9.8\r\n  CasperJS version:   1.0.0\r\n#################################################\r\n```\r\n\r\n## Backwards breaking changes\r\nThe `before_capture` hook is great, but didn't support asynchronous actions such as AJAXing in content, etc, as Wraith's internal snap file would simply run the before_capture module and then continue, assuming the code was executed instantly.\r\n\r\nNow, an additional parameter (the `ready` callback function) is passed to the before_capture module, which explicitly requires the module to call the callback before Phantom/Casper will continue. This means the user can put in arbitrary wait times, or perform any other asynchronous action, only calling the callback when they're ready.\r\n\r\n```javascript\r\nmodule.exports = function (casper, ready) {\r\n    // make Wraith wait a bit longer before taking the screenshot\r\n    casper.wait(2000, ready); // you MUST call the ready() callback for Wraith to continue\r\n}\r\n```","created_at":"2015-12-23T16:22:24Z","updated_at":"2015-12-23T22:00:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17aebca4a30d547e1ae5ce243dcb4982cfc6c9d9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BBC-News/wraith/pulls/361/commits","review_comments_url":"https://api.github.com/repos/BBC-News/wraith/pulls/361/comments","review_comment_url":"https://api.github.com/repos/BBC-News/wraith/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BBC-News/wraith/issues/361/comments","statuses_url":"https://api.github.com/repos/BBC-News/wraith/statuses/b4926e881eb7dc6cda2289ef9d256419a5026f49","head":{"label":"BBC-News:wraith-3.1","ref":"wraith-3.1","sha":"b4926e881eb7dc6cda2289ef9d256419a5026f49","user":{"login":"BBC-News","id":1401475,"avatar_url":"https://avatars.githubusercontent.com/u/1401475?v=3","gravatar_id":"","url":"https://api.github.com/users/BBC-News","html_url":"https://github.com/BBC-News","followers_url":"https://api.github.com/users/BBC-News/followers","following_url":"https://api.github.com/users/BBC-News/following{/other_user}","gists_url":"https://api.github.com/users/BBC-News/gists{/gist_id}","starred_url":"https://api.github.com/users/BBC-News/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBC-News/subscriptions","organizations_url":"https://api.github.com/users/BBC-News/orgs","repos_url":"https://api.github.com/users/BBC-News/repos","events_url":"https://api.github.com/users/BBC-News/events{/privacy}","received_events_url":"https://api.github.com/users/BBC-News/received_events","type":"Organization","site_admin":false},"repo":{"id":7777332,"name":"wraith","full_name":"BBC-News/wraith","owner":{"login":"BBC-News","id":1401475,"avatar_url":"https://avatars.githubusercontent.com/u/1401475?v=3","gravatar_id":"","url":"https://api.github.com/users/BBC-News","html_url":"https://github.com/BBC-News","followers_url":"https://api.github.com/users/BBC-News/followers","following_url":"https://api.github.com/users/BBC-News/following{/other_user}","gists_url":"https://api.github.com/users/BBC-News/gists{/gist_id}","starred_url":"https://api.github.com/users/BBC-News/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBC-News/subscriptions","organizations_url":"https://api.github.com/users/BBC-News/orgs","repos_url":"https://api.github.com/users/BBC-News/repos","events_url":"https://api.github.com/users/BBC-News/events{/privacy}","received_events_url":"https://api.github.com/users/BBC-News/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BBC-News/wraith","description":"Wraith — A responsive screenshot comparison tool","fork":false,"url":"https://api.github.com/repos/BBC-News/wraith","forks_url":"https://api.github.com/repos/BBC-News/wraith/forks","keys_url":"https://api.github.com/repos/BBC-News/wraith/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BBC-News/wraith/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BBC-News/wraith/teams","hooks_url":"https://api.github.com/repos/BBC-News/wraith/hooks","issue_events_url":"https://api.github.com/repos/BBC-News/wraith/issues/events{/number}","events_url":"https://api.github.com/repos/BBC-News/wraith/events","assignees_url":"https://api.github.com/repos/BBC-News/wraith/assignees{/user}","branches_url":"https://api.github.com/repos/BBC-News/wraith/branches{/branch}","tags_url":"https://api.github.com/repos/BBC-News/wraith/tags","blobs_url":"https://api.github.com/repos/BBC-News/wraith/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BBC-News/wraith/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BBC-News/wraith/git/refs{/sha}","trees_url":"https://api.github.com/repos/BBC-News/wraith/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BBC-News/wraith/statuses/{sha}","languages_url":"https://api.github.com/repos/BBC-News/wraith/languages","stargazers_url":"https://api.github.com/repos/BBC-News/wraith/stargazers","contributors_url":"https://api.github.com/repos/BBC-News/wraith/contributors","subscribers_url":"https://api.github.com/repos/BBC-News/wraith/subscribers","subscription_url":"https://api.github.com/repos/BBC-News/wraith/subscription","commits_url":"https://api.github.com/repos/BBC-News/wraith/commits{/sha}","git_commits_url":"https://api.github.com/repos/BBC-News/wraith/git/commits{/sha}","comments_url":"https://api.github.com/repos/BBC-News/wraith/comments{/number}","issue_comment_url":"https://api.github.com/repos/BBC-News/wraith/issues/comments{/number}","contents_url":"https://api.github.com/repos/BBC-News/wraith/contents/{+path}","compare_url":"https://api.github.com/repos/BBC-News/wraith/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BBC-News/wraith/merges","archive_url":"https://api.github.com/repos/BBC-News/wraith/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BBC-News/wraith/downloads","issues_url":"https://api.github.com/repos/BBC-News/wraith/issues{/number}","pulls_url":"https://api.github.com/repos/BBC-News/wraith/pulls{/number}","milestones_url":"https://api.github.com/repos/BBC-News/wraith/milestones{/number}","notifications_url":"https://api.github.com/repos/BBC-News/wraith/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BBC-News/wraith/labels{/name}","releases_url":"https://api.github.com/repos/BBC-News/wraith/releases{/id}","created_at":"2013-01-23T15:26:31Z","updated_at":"2015-12-23T15:00:37Z","pushed_at":"2015-12-23T21:24:48Z","git_url":"git://github.com/BBC-News/wraith.git","ssh_url":"git@github.com:BBC-News/wraith.git","clone_url":"https://github.com/BBC-News/wraith.git","svn_url":"https://github.com/BBC-News/wraith","homepage":"http://bbc-news.github.io/wraith/","size":122672,"stargazers_count":3372,"watchers_count":3372,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":203,"mirror_url":null,"open_issues_count":31,"forks":203,"open_issues":31,"watchers":3372,"default_branch":"master"}},"base":{"label":"BBC-News:master","ref":"master","sha":"90af042466f714798836569d5efed2fac733b558","user":{"login":"BBC-News","id":1401475,"avatar_url":"https://avatars.githubusercontent.com/u/1401475?v=3","gravatar_id":"","url":"https://api.github.com/users/BBC-News","html_url":"https://github.com/BBC-News","followers_url":"https://api.github.com/users/BBC-News/followers","following_url":"https://api.github.com/users/BBC-News/following{/other_user}","gists_url":"https://api.github.com/users/BBC-News/gists{/gist_id}","starred_url":"https://api.github.com/users/BBC-News/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBC-News/subscriptions","organizations_url":"https://api.github.com/users/BBC-News/orgs","repos_url":"https://api.github.com/users/BBC-News/repos","events_url":"https://api.github.com/users/BBC-News/events{/privacy}","received_events_url":"https://api.github.com/users/BBC-News/received_events","type":"Organization","site_admin":false},"repo":{"id":7777332,"name":"wraith","full_name":"BBC-News/wraith","owner":{"login":"BBC-News","id":1401475,"avatar_url":"https://avatars.githubusercontent.com/u/1401475?v=3","gravatar_id":"","url":"https://api.github.com/users/BBC-News","html_url":"https://github.com/BBC-News","followers_url":"https://api.github.com/users/BBC-News/followers","following_url":"https://api.github.com/users/BBC-News/following{/other_user}","gists_url":"https://api.github.com/users/BBC-News/gists{/gist_id}","starred_url":"https://api.github.com/users/BBC-News/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BBC-News/subscriptions","organizations_url":"https://api.github.com/users/BBC-News/orgs","repos_url":"https://api.github.com/users/BBC-News/repos","events_url":"https://api.github.com/users/BBC-News/events{/privacy}","received_events_url":"https://api.github.com/users/BBC-News/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BBC-News/wraith","description":"Wraith — A responsive screenshot comparison tool","fork":false,"url":"https://api.github.com/repos/BBC-News/wraith","forks_url":"https://api.github.com/repos/BBC-News/wraith/forks","keys_url":"https://api.github.com/repos/BBC-News/wraith/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BBC-News/wraith/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BBC-News/wraith/teams","hooks_url":"https://api.github.com/repos/BBC-News/wraith/hooks","issue_events_url":"https://api.github.com/repos/BBC-News/wraith/issues/events{/number}","events_url":"https://api.github.com/repos/BBC-News/wraith/events","assignees_url":"https://api.github.com/repos/BBC-News/wraith/assignees{/user}","branches_url":"https://api.github.com/repos/BBC-News/wraith/branches{/branch}","tags_url":"https://api.github.com/repos/BBC-News/wraith/tags","blobs_url":"https://api.github.com/repos/BBC-News/wraith/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BBC-News/wraith/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BBC-News/wraith/git/refs{/sha}","trees_url":"https://api.github.com/repos/BBC-News/wraith/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BBC-News/wraith/statuses/{sha}","languages_url":"https://api.github.com/repos/BBC-News/wraith/languages","stargazers_url":"https://api.github.com/repos/BBC-News/wraith/stargazers","contributors_url":"https://api.github.com/repos/BBC-News/wraith/contributors","subscribers_url":"https://api.github.com/repos/BBC-News/wraith/subscribers","subscription_url":"https://api.github.com/repos/BBC-News/wraith/subscription","commits_url":"https://api.github.com/repos/BBC-News/wraith/commits{/sha}","git_commits_url":"https://api.github.com/repos/BBC-News/wraith/git/commits{/sha}","comments_url":"https://api.github.com/repos/BBC-News/wraith/comments{/number}","issue_comment_url":"https://api.github.com/repos/BBC-News/wraith/issues/comments{/number}","contents_url":"https://api.github.com/repos/BBC-News/wraith/contents/{+path}","compare_url":"https://api.github.com/repos/BBC-News/wraith/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BBC-News/wraith/merges","archive_url":"https://api.github.com/repos/BBC-News/wraith/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BBC-News/wraith/downloads","issues_url":"https://api.github.com/repos/BBC-News/wraith/issues{/number}","pulls_url":"https://api.github.com/repos/BBC-News/wraith/pulls{/number}","milestones_url":"https://api.github.com/repos/BBC-News/wraith/milestones{/number}","notifications_url":"https://api.github.com/repos/BBC-News/wraith/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BBC-News/wraith/labels{/name}","releases_url":"https://api.github.com/repos/BBC-News/wraith/releases{/id}","created_at":"2013-01-23T15:26:31Z","updated_at":"2015-12-23T15:00:37Z","pushed_at":"2015-12-23T21:24:48Z","git_url":"git://github.com/BBC-News/wraith.git","ssh_url":"git@github.com:BBC-News/wraith.git","clone_url":"https://github.com/BBC-News/wraith.git","svn_url":"https://github.com/BBC-News/wraith","homepage":"http://bbc-news.github.io/wraith/","size":122672,"stargazers_count":3372,"watchers_count":3372,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":203,"mirror_url":null,"open_issues_count":31,"forks":203,"open_issues":31,"watchers":3372,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/361"},"html":{"href":"https://github.com/BBC-News/wraith/pull/361"},"issue":{"href":"https://api.github.com/repos/BBC-News/wraith/issues/361"},"comments":{"href":"https://api.github.com/repos/BBC-News/wraith/issues/361/comments"},"review_comments":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/361/comments"},"review_comment":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BBC-News/wraith/pulls/361/commits"},"statuses":{"href":"https://api.github.com/repos/BBC-News/wraith/statuses/b4926e881eb7dc6cda2289ef9d256419a5026f49"}}}}