{"action":"created","comment":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/44791273","id":44791273,"diff_hunk":"@@ -0,0 +1,364 @@\n+'use strict';\n+var _ = require('lodash'),\n+    q = require('q'),\n+    CaptureSession = require('../../../lib/capture-session'),\n+    SuiteRunner = require('../../../lib/runner/suite-runner'),\n+    StateRunner = require('../../../lib/runner/state-runner'),\n+    Config = require('../../../lib/config'),\n+    util = require('../../util');\n+\n+describe('runner/SuiteRunner', function() {\n+    var sandbox = sinon.sandbox.create(),\n+        browser,\n+        config;\n+\n+    beforeEach(function() {\n+        sandbox.stub(StateRunner.prototype);\n+        sandbox.stub(CaptureSession.prototype);\n+        browser = util.browserWithId('default-browser');\n+        config = sinon.createStubInstance(Config);\n+\n+        StateRunner.prototype.run.returns(q.resolve());\n+        CaptureSession.prototype.runHook.returns(q.resolve());\n+\n+        sandbox.stub(browser, 'openRelative');\n+        browser.openRelative.returns(q.resolve());\n+    });\n+\n+    afterEach(function() {\n+        sandbox.restore();\n+    });\n+\n+    function mkRunner_() {\n+        return SuiteRunner.create(browser, config);\n+    }\n+\n+    function mkSuiteStub_(opts) {\n+        opts = opts || {};\n+        return _.defaults(opts, {\n+            hasStates: opts.states && opts.states.length > 0,\n+            url: 'some-default-url',\n+            beforeHook: sinon.spy(),\n+            afterHook: sinon.spy(),\n+            states: [],\n+            runPostActions: sinon.stub()\n+        });\n+    }\n+\n+    function run_(suite) {\n+        var runner = mkRunner_();\n+        return runner.run(suite);\n+    }\n+\n+    describe('run', function() {\n+        it('should emit `beginSuite` event', function() {\n+            var onBeginSuite = sinon.spy().named('onBeginSuite'),\n+                suite = mkSuiteStub_(),\n+                runner = SuiteRunner.create(browser, config);\n+            browser.id = 'browser';\n+\n+            runner.on('beginSuite', onBeginSuite);\n+            return runner.run(suite)\n+                .then(function() {\n+                    assert.calledWith(onBeginSuite, {\n+                        suite: suite,\n+                        browserId: 'browser'\n+                    });\n+                });\n+        });\n+\n+        it('should emit `endSuite` event', function() {\n+            var onEndSuite = sinon.spy().named('onEndSuite'),\n+                suite = mkSuiteStub_(),\n+                runner = SuiteRunner.create(browser, config);\n+            browser.id = 'browser';\n+\n+            runner.on('endSuite', onEndSuite);\n+            return runner.run(suite)\n+                .then(function() {\n+                    assert.calledWith(onEndSuite, {\n+                        suite: suite,\n+                        browserId: 'browser'\n+                    });\n+                });\n+        });\n+\n+        it('should emit events in correct order', function() {\n+            var onBeginSuite = sinon.spy().named('onBeginSuite'),\n+                onEndSuite = sinon.spy().named('onEndSuite'),\n+                suite = mkSuiteStub_(),\n+                runner = mkRunner_();\n+\n+            runner.on('beginSuite', onBeginSuite);\n+            runner.on('endSuite', onEndSuite);\n+\n+            return runner.run(suite)\n+                .then(function() {\n+                    assert.callOrder(\n+                        onBeginSuite,\n+                        onEndSuite\n+                    );\n+                });\n+        });\n+\n+        it('should not call any hook if no states', function() {\n+            var suite = mkSuiteStub_();\n+\n+            return run_(suite)\n+                .then(function() {\n+                    assert.notCalled(CaptureSession.prototype.runHook);\n+                });\n+        });\n+\n+        it('should call `before` hook if there are some states', function() {\n+            var suite = mkSuiteStub_({\n+                    states: [util.makeStateStub()]\n+                });\n+\n+            return run_(suite)\n+                .then(function() {\n+                    assert.calledWith(CaptureSession.prototype.runHook, suite.beforeHook, suite);\n+                });\n+        });\n+\n+        it('should run states', function() {\n+            var state = util.makeStateStub(),\n+                suite = mkSuiteStub_({\n+                    states: [state]\n+                });\n+\n+            return run_(suite)\n+                .then(function() {\n+                    assert.calledWith(StateRunner.prototype.run, state);\n+                });\n+        });\n+\n+        describe('if `beforeHook` failed', function() {\n+            var suite;\n+\n+            beforeEach(function() {\n+                suite = mkSuiteStub_({\n+                    states: [util.makeStateStub()]\n+                });\n+\n+                CaptureSession.prototype.runHook.withArgs(suite.beforeHook).returns(q.reject());\n+            });\n+\n+            it('should fail', function() {\n+                CaptureSession.prototype.runHook.withArgs(suite.beforeHook).returns(q.reject('some-error'));\n+\n+                return assert.isRejected(run_(suite), /some-error/);\n+            });\n+\n+            it('should not run states', function() {\n+                return run_(suite)\n+                    .fail(function() {\n+                        assert.notCalled(StateRunner.prototype.run);\n+                    });\n+            });\n+\n+            it('should not run `afterHook`', function() {\n+                return run_(suite)\n+                    .fail(function() {\n+                        assert.neverCalledWith(CaptureSession.prototype.runHook, suite.afterHook);\n+                    });\n+            });\n+\n+            it('should not run post actions', function() {\n+                return run_(suite)\n+                    .fail(function() {\n+                        assert.notCalled(suite.runPostActions);\n+                    });\n+            });\n+        });\n+\n+        it('should run next state only after previous has been finished', function() {\n+            var state1 = util.makeStateStub(),\n+                state2 = util.makeStateStub(),\n+                mediator = sinon.spy(),\n+                suite = mkSuiteStub_({\n+                    states: [state1, state2]\n+                });\n+\n+            StateRunner.prototype.run.withArgs(state1).returns(q.delay(1).then(mediator));\n+\n+            return run_(suite)\n+                .then(function() {\n+                    assert.callOrder(\n+                        StateRunner.prototype.run.withArgs(state1).named('state1 runner'),\n+                        mediator.named('middle function'),","path":"test/unit/runner/suite-runner.js","position":189,"original_position":189,"commit_id":"199b34ce75a7b28170b60940b28d90a752bfd432","original_commit_id":"199b34ce75a7b28170b60940b28d90a752bfd432","user":{"login":"tormozz48","id":996162,"avatar_url":"https://avatars.githubusercontent.com/u/996162?v=3","gravatar_id":"","url":"https://api.github.com/users/tormozz48","html_url":"https://github.com/tormozz48","followers_url":"https://api.github.com/users/tormozz48/followers","following_url":"https://api.github.com/users/tormozz48/following{/other_user}","gists_url":"https://api.github.com/users/tormozz48/gists{/gist_id}","starred_url":"https://api.github.com/users/tormozz48/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tormozz48/subscriptions","organizations_url":"https://api.github.com/users/tormozz48/orgs","repos_url":"https://api.github.com/users/tormozz48/repos","events_url":"https://api.github.com/users/tormozz48/events{/privacy}","received_events_url":"https://api.github.com/users/tormozz48/received_events","type":"User","site_admin":false},"body":"Насколько я понимаю, это чтобы разные стабы отличать между собой","created_at":"2015-11-13T15:08:42Z","updated_at":"2015-11-13T15:08:42Z","html_url":"https://github.com/gemini-testing/gemini/pull/292#discussion_r44791273","pull_request_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/292","_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments/44791273"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/292#discussion_r44791273"},"pull_request":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/292"}}},"pull_request":{"url":"https://api.github.com/repos/gemini-testing/gemini/pulls/292","id":50111733,"html_url":"https://github.com/gemini-testing/gemini/pull/292","diff_url":"https://github.com/gemini-testing/gemini/pull/292.diff","patch_url":"https://github.com/gemini-testing/gemini/pull/292.patch","issue_url":"https://api.github.com/repos/gemini-testing/gemini/issues/292","number":292,"state":"open","locked":false,"title":"WIP: fix post actions","user":{"login":"j0tunn","id":7701229,"avatar_url":"https://avatars.githubusercontent.com/u/7701229?v=3","gravatar_id":"","url":"https://api.github.com/users/j0tunn","html_url":"https://github.com/j0tunn","followers_url":"https://api.github.com/users/j0tunn/followers","following_url":"https://api.github.com/users/j0tunn/following{/other_user}","gists_url":"https://api.github.com/users/j0tunn/gists{/gist_id}","starred_url":"https://api.github.com/users/j0tunn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j0tunn/subscriptions","organizations_url":"https://api.github.com/users/j0tunn/orgs","repos_url":"https://api.github.com/users/j0tunn/repos","events_url":"https://api.github.com/users/j0tunn/events{/privacy}","received_events_url":"https://api.github.com/users/j0tunn/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-09T11:31:33Z","updated_at":"2015-11-13T15:08:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86518bc32fd57d8f4efa137c74bf0d1a4a5e6439","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/292/commits","review_comments_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/292/comments","review_comment_url":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/issues/292/comments","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/199b34ce75a7b28170b60940b28d90a752bfd432","head":{"label":"gemini-testing:fix/post.actions","ref":"fix/post.actions","sha":"199b34ce75a7b28170b60940b28d90a752bfd432","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","created_at":"2014-02-11T14:58:41Z","updated_at":"2015-11-12T09:38:01Z","pushed_at":"2015-11-13T15:08:23Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":null,"size":4358,"stargazers_count":462,"watchers_count":462,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":68,"forks":54,"open_issues":68,"watchers":462,"default_branch":"master"}},"base":{"label":"gemini-testing:master","ref":"master","sha":"9c4cfe3ca41b96f99b29354588aac2f8dbbe4e79","user":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"repo":{"id":16734168,"name":"gemini","full_name":"gemini-testing/gemini","owner":{"login":"gemini-testing","id":11424134,"avatar_url":"https://avatars.githubusercontent.com/u/11424134?v=3","gravatar_id":"","url":"https://api.github.com/users/gemini-testing","html_url":"https://github.com/gemini-testing","followers_url":"https://api.github.com/users/gemini-testing/followers","following_url":"https://api.github.com/users/gemini-testing/following{/other_user}","gists_url":"https://api.github.com/users/gemini-testing/gists{/gist_id}","starred_url":"https://api.github.com/users/gemini-testing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gemini-testing/subscriptions","organizations_url":"https://api.github.com/users/gemini-testing/orgs","repos_url":"https://api.github.com/users/gemini-testing/repos","events_url":"https://api.github.com/users/gemini-testing/events{/privacy}","received_events_url":"https://api.github.com/users/gemini-testing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gemini-testing/gemini","description":"Utility for regression testing of web pages using screenshots","fork":false,"url":"https://api.github.com/repos/gemini-testing/gemini","forks_url":"https://api.github.com/repos/gemini-testing/gemini/forks","keys_url":"https://api.github.com/repos/gemini-testing/gemini/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gemini-testing/gemini/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gemini-testing/gemini/teams","hooks_url":"https://api.github.com/repos/gemini-testing/gemini/hooks","issue_events_url":"https://api.github.com/repos/gemini-testing/gemini/issues/events{/number}","events_url":"https://api.github.com/repos/gemini-testing/gemini/events","assignees_url":"https://api.github.com/repos/gemini-testing/gemini/assignees{/user}","branches_url":"https://api.github.com/repos/gemini-testing/gemini/branches{/branch}","tags_url":"https://api.github.com/repos/gemini-testing/gemini/tags","blobs_url":"https://api.github.com/repos/gemini-testing/gemini/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gemini-testing/gemini/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gemini-testing/gemini/git/refs{/sha}","trees_url":"https://api.github.com/repos/gemini-testing/gemini/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gemini-testing/gemini/statuses/{sha}","languages_url":"https://api.github.com/repos/gemini-testing/gemini/languages","stargazers_url":"https://api.github.com/repos/gemini-testing/gemini/stargazers","contributors_url":"https://api.github.com/repos/gemini-testing/gemini/contributors","subscribers_url":"https://api.github.com/repos/gemini-testing/gemini/subscribers","subscription_url":"https://api.github.com/repos/gemini-testing/gemini/subscription","commits_url":"https://api.github.com/repos/gemini-testing/gemini/commits{/sha}","git_commits_url":"https://api.github.com/repos/gemini-testing/gemini/git/commits{/sha}","comments_url":"https://api.github.com/repos/gemini-testing/gemini/comments{/number}","issue_comment_url":"https://api.github.com/repos/gemini-testing/gemini/issues/comments{/number}","contents_url":"https://api.github.com/repos/gemini-testing/gemini/contents/{+path}","compare_url":"https://api.github.com/repos/gemini-testing/gemini/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gemini-testing/gemini/merges","archive_url":"https://api.github.com/repos/gemini-testing/gemini/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gemini-testing/gemini/downloads","issues_url":"https://api.github.com/repos/gemini-testing/gemini/issues{/number}","pulls_url":"https://api.github.com/repos/gemini-testing/gemini/pulls{/number}","milestones_url":"https://api.github.com/repos/gemini-testing/gemini/milestones{/number}","notifications_url":"https://api.github.com/repos/gemini-testing/gemini/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gemini-testing/gemini/labels{/name}","releases_url":"https://api.github.com/repos/gemini-testing/gemini/releases{/id}","created_at":"2014-02-11T14:58:41Z","updated_at":"2015-11-12T09:38:01Z","pushed_at":"2015-11-13T15:08:23Z","git_url":"git://github.com/gemini-testing/gemini.git","ssh_url":"git@github.com:gemini-testing/gemini.git","clone_url":"https://github.com/gemini-testing/gemini.git","svn_url":"https://github.com/gemini-testing/gemini","homepage":null,"size":4358,"stargazers_count":462,"watchers_count":462,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":54,"mirror_url":null,"open_issues_count":68,"forks":54,"open_issues":68,"watchers":462,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/292"},"html":{"href":"https://github.com/gemini-testing/gemini/pull/292"},"issue":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/292"},"comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/issues/292/comments"},"review_comments":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/292/comments"},"review_comment":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gemini-testing/gemini/pulls/292/commits"},"statuses":{"href":"https://api.github.com/repos/gemini-testing/gemini/statuses/199b34ce75a7b28170b60940b28d90a752bfd432"}}}}